469,592 Members | 1,808 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

Warning: mysql_fetch_array(): supplied argument

Hello! All I have a Error message saying that:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in /home/rocks/public_html/colorado3.php on line 32

I have error on this code below:

<html>
<head>
<titleColorado</title>
</head>
<body>
<h1>Social Security Offices</h1>
</html>
<?php
$con = mysql_connect("localhost","admin","*******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("office", $con);

$id = $_GET['id'];

$result = mysql_query("SELECT * FROM sso WHERE state = $id");

echo "<table border='2'>
<tr>
<th>Address1</th>
<th>Address2</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>Telephone</th>
</tr>";
while($row = mysql_fetch_array($result)) {
$neprocks_office = $row->neprocks_office; $addr_st1 = $row->addr_st1;
$addr_st2 = $row->addr_st2; $city = $row->city;
$state = $row->state; $zip = $row->zip; $telephone = $row->telephone;

echo "<tr>";
echo "<td>" . $row['addr_st1'] . "</td>";
echo "<td>" . $row['addr_st2'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['state'] . "</td>";
echo "<td>" . $row['zip'] . "</td>";
echo "<td>" . $row['telephone'] . "</td>";
echo "</tr>";
}
echo "</table>";mysql_close($con);
?>

Mar 14 '07 #1
1 1852
mysql_select_db("office", $con) or die(mysql_error());

$result = mysql_query("SELECT * FROM sso WHERE state = $id") or
die(mysql_error());

but please also read docs about security - never put $_GET or $_POST
directly into a mysql-query...

my******@gmail.com schrieb:
Hello! All I have a Error message saying that:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in /home/rocks/public_html/colorado3.php on line 32

I have error on this code below:

<html>
<head>
<titleColorado</title>
</head>
<body>
<h1>Social Security Offices</h1>
</html>
<?php
$con = mysql_connect("localhost","admin","*******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("office", $con);

$id = $_GET['id'];

$result = mysql_query("SELECT * FROM sso WHERE state = $id");

echo "<table border='2'>
<tr>
<th>Address1</th>
<th>Address2</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>Telephone</th>
</tr>";
while($row = mysql_fetch_array($result)) {
$neprocks_office = $row->neprocks_office; $addr_st1 = $row->addr_st1;
$addr_st2 = $row->addr_st2; $city = $row->city;
$state = $row->state; $zip = $row->zip; $telephone = $row->telephone;

echo "<tr>";
echo "<td>" . $row['addr_st1'] . "</td>";
echo "<td>" . $row['addr_st2'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['state'] . "</td>";
echo "<td>" . $row['zip'] . "</td>";
echo "<td>" . $row['telephone'] . "</td>";
echo "</tr>";
}
echo "</table>";mysql_close($con);
?>
Mar 14 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.