Jump to content


Photo

Help making hello world PHP/Mysql app


  • Please log in to reply
1 reply to this topic

#1 antiNeo

antiNeo
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 27 April 2006 - 04:33 PM

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>Nick
Name</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.

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 27 April 2006 - 04:54 PM

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:
$result = mysql_query("SELECT * FROM personnel",$db);
to:
$result = mysql_query("SELECT * FROM personnel", $db) or die("SQL Query error: " . mysql_error());
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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users