472,096 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

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 1971
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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.