Click here to Skip to main content
15,887,945 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
require_once 'db.php';

$query = "SELECT = FROM quotes ORDER By rand() LIMIT 1";

$result = mysqli_query($con, $query);

while($row = mysqli_fetch_array($result)) {
print(json_encode($row['quote']));
}


?>

What I have tried:

I am no sure what to do as i am not experienced with PHP coding, help required URGENTLY!
Posted
Updated 6-Apr-16 1:38am
v3
Comments
phil.o 6-Apr-16 7:30am    
Look at your SQL query ; there is a huge and obvious mistake.
Member 12440221 6-Apr-16 7:58am    
plz tell me
Member 12440221 6-Apr-16 8:08am    
i dont know what to do please tell me
phil.o 6-Apr-16 8:13am    
Did you have a look at the SQL query yet?
Member 12440221 6-Apr-16 8:27am    
yes but i dont get what is wrong. i replaced the second equal sign in the code but same warnings show up.

1 solution

Um.
SQL
SELECT = FROM quotes ORDER By rand() LIMIT 1
Try
SQL
SELECT * FROM quotes ORDER By rand() LIMIT 1

But better, specify the list of columns. That way, you only get the ones you need so the transfer is more efficient, you know the order in which they will arrive, and your app doesn't crash if the DB design is tweaked.
 
Share this answer
 
Comments
Member 12440221 6-Apr-16 7:44am    
I dont get this stuff.
can you tell me what to edit or write the code so i can copy it.
:)
OriginalGriff 6-Apr-16 7:48am    
You are kidding, aren't you?
You need to identify the one and only, single character difference between two lines of code and make that change in your app, and you can't do it when they are both written down in front of you?
Development is about two things: details, and thinking.
You need to drink another coffee, I suspect...
Member 12440221 6-Apr-16 7:50am    
i dont know about coding. i got this code of a tuorial.
OriginalGriff 6-Apr-16 7:58am    
Then you need to go back to the start of the whole tutorial and work your way through it - you aren't going to learn anything useful if you skip ahead and don't fully understand the earlier stuff!
Member 12440221 6-Apr-16 8:03am    
i have, i did every thing he explaied, but it is an old tutorial

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900