antiNeo Posted April 27, 2006 Share Posted April 27, 2006 I am trying to write a hello world type php/mysql app, but I am getting an error. See here: [a href=\"http://peltkore.net/~antineo/viewdb.php\" target=\"_blank\"]http://peltkore.net/~antineo/viewdb.php[/a]here is the code:<HTML><?php$db = mysql_connect("localhost", "antineo", "my_password");mysql_select_db("antineo",$db);$result = mysql_query("SELECT * FROM personnel",$db);echo "<TABLE>";echo"<TR><TD><B>Full Name</B><TD><B>NickName</B><TD><B>Salary</B></TR>";while($myrow = mysql_fetch_array($result)){echo "<TR><TD>";echo $myrow["firstname"];echo " ";echo $myrow["lastname"];echo "<TD>";echo $myrow["nick"];echo "<TD>";echo $myrow["salary"];}echo "</TABLE>";?></HTML>Any ideas? PHP/mySql is starting to confuse me. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 27, 2006 Share Posted April 27, 2006 If you are getting that error messahe then that error is usually due to an error in your SQL query. To see why your query is failing change this line:[code]$result = mysql_query("SELECT * FROM personnel",$db);[/code]to:[code]$result = mysql_query("SELECT * FROM personnel", $db) or die("SQL Query error: " . mysql_error());[/code]Now by looking at your query evertink is fine, but I have a feeling you have mistyped the table name (personnel).If you dont understand the error message that will be returned when you run your code again then post it here and we'll explain why. Quote Link to comment 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.