H3mp
07-24-2011, 01:07 AM
I've been searching for answers to this problem for a little while now to no avail. Im hesitant to post a uqestion that may have been answered, but here it goes.
I'm learning how to use MySQL and PHP. I have created the database, but when I try to display it I get the following error.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/bail/public_html/bailfiles/index.php on line 15
I have edited the syntax over and over and over and over but I either get a new error until I reverse the tweak, or I get the same message.
Here is the database information
DatabaseName: bail_bail
TableName: bailfiles
contains the following data fields:
id = 4 digit integer, auto-increment
fname = 30 digits varchar
lname = 30 digit varchar
phon = 12 digit varchar
Here is the code in my index.php file
<html>
<head>
<title>
Smith Bail Files Database by Justin
</title>
</head>
<body bgcolor="000000" text="00ff00" link="00ff00" vlink="00ff00">
<?php
mysql_connect ("localhost", "DATABASEUSERNAME", "DATABASEPASSWORD") or die ('Could not connect to the MySQL Database because : ' . mysql_error());
mysql_select_db ("bail_bail ");
$query = mysql_query ("SELECT * FROM bailfiles ");
while ($row = mysql_fetch_array(query))
{
echo "<br />ID: ".$row[id];
echo "<br />First Name: ".$row[fname];
echo "<br />Last Name: ".$row[lname];
echo "<br />Phone: ".$row[phon];
}
?>
</body>
</html>
I have verified numerous times I am using the proper variable names and database information. I am completely stuck. I wouldn't be asking for help if I thought I could hack it until I figured it out, but Im getting burnt on the topic.
Any ideas?
I'm learning how to use MySQL and PHP. I have created the database, but when I try to display it I get the following error.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/bail/public_html/bailfiles/index.php on line 15
I have edited the syntax over and over and over and over but I either get a new error until I reverse the tweak, or I get the same message.
Here is the database information
DatabaseName: bail_bail
TableName: bailfiles
contains the following data fields:
id = 4 digit integer, auto-increment
fname = 30 digits varchar
lname = 30 digit varchar
phon = 12 digit varchar
Here is the code in my index.php file
<html>
<head>
<title>
Smith Bail Files Database by Justin
</title>
</head>
<body bgcolor="000000" text="00ff00" link="00ff00" vlink="00ff00">
<?php
mysql_connect ("localhost", "DATABASEUSERNAME", "DATABASEPASSWORD") or die ('Could not connect to the MySQL Database because : ' . mysql_error());
mysql_select_db ("bail_bail ");
$query = mysql_query ("SELECT * FROM bailfiles ");
while ($row = mysql_fetch_array(query))
{
echo "<br />ID: ".$row[id];
echo "<br />First Name: ".$row[fname];
echo "<br />Last Name: ".$row[lname];
echo "<br />Phone: ".$row[phon];
}
?>
</body>
</html>
I have verified numerous times I am using the proper variable names and database information. I am completely stuck. I wouldn't be asking for help if I thought I could hack it until I figured it out, but Im getting burnt on the topic.
Any ideas?