Jump to content

Help making hello world PHP/Mysql app


antiNeo

Recommended Posts

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.