slj90 Posted December 11, 2009 Share Posted December 11, 2009 Hi, I am trying to display data from a table in mysql with the following code, however when the page loads it just shows lines of '=='. Everything is spelt correctly and there is data in the table. <?php $connection = mysql_connect("localhost", "root"); mysql_select_db("people", $connection); $query = "SELECT * FROM customer"; $result = mysql_query ($query); while ($row = mysql_fetch_array($result)) { print $row["customerID"]; print "=="; //print 2 equals signs print $row["surname"]. "<br>"; } ?> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/184728-why-is-this-code-not-working/ Share on other sites More sharing options...
.josh Posted December 11, 2009 Share Posted December 11, 2009 if you are seeing lots of "==" then you are connecting okay. So then it can only be: a) you said you double checked and you spelled the column names correctly. This is the most common cause of bug. Double check. Make sure you capitalized correctly (case-sensitive!). print_r($row); in the loop to dump out what is in $row b) are you using the right table name? c) are you using the right database? Quote Link to comment https://forums.phpfreaks.com/topic/184728-why-is-this-code-not-working/#findComment-975197 Share on other sites More sharing options...
slj90 Posted December 11, 2009 Author Share Posted December 11, 2009 Thanks for your response. Im new to PHP and didn't realise it was case sensitive. The code now works, thanks alot! Quote Link to comment https://forums.phpfreaks.com/topic/184728-why-is-this-code-not-working/#findComment-975199 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.