Jump to content

Why is this code not working


slj90

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/184728-why-is-this-code-not-working/
Share on other sites

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?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.