0

Comparison operation issue SQL

Ok so I'm trying to compare two columns which are both int(11). Here is my query... SELECT * FROM test1 WHERE Priority > Status I keep getting this error whenever I run the sql query in my php code "Uncaught Error: mysqli_stmt object is not fully initialized in [File location]:20 Stack trace: #0 [File location] mysqli_stmt_execute(Object(mysqli_stmt)) #1 {main}" also here is my php code if it helps... $query = "SELECT * FROM test1 WHERE Status < Priority"; $dbc = mysqli_stmt_init($Conn); mysqli_stmt_prepare($dbc, $query); mysqli_stmt_execute($q); //error occurs here Thanks in advance for any help

30th Jan 2021, 11:21 PM
Ollie Q
Ollie Q - avatar
4 odpowiedzi
+ 1
$q
31st Jan 2021, 1:55 AM
Anastacia Ru
Anastacia Ru - avatar
+ 1
Assuming <$Conn> is a valid connection object, I think you meant to do this instead. if( mysqli_stmt_prepare( $dbc, $query ) ) { mysqli_stmt_execute( $dbc ); } mysqli_stmt_execute() accepts a statement object, and here you are passing <$q> which is unknown.
31st Jan 2021, 2:05 AM
Ipang
+ 1
Thanks Ipang & Anastacia Ru for your help so far. I’ve checked $Conn & it works & $q is just a spelling issue from when i copied it out from the code i’d written in another program. Also implemented what you suggested & it does work to a degree because the query doesn’t execute but it still doesn’t fix the query. Any other suggestions?
31st Jan 2021, 3:00 AM
Ollie Q
Ollie Q - avatar
+ 1
Ollie Q I don't get this part, "the query doesn't execute but it still doesn't fix the query" What DBMS is in use? Does the query work if you run it directly on the server (without using PHP)? maybe through command line interface? It may help if you can also share the structure of 'test1' table. And your updated PHP code (that still doesn't work).
31st Jan 2021, 3:10 AM
Ipang