note 86579 rejected from function.mysql-fetch-array by danbrown
| From: | danbrown@php.net | Date: | Fri, 24 Oct 2008 13:48:42 +0000 |
| Subject: | note 86579 rejected from function.mysql-fetch-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145692@lists.php.net to get a copy of this message | ||
Note Submitter: marquee_fb14 at yahoo dot com
----
Im a beginner and I just starting my first code to try if my MySQL and PHP is going will work. But
the result is always "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mysql_test.php on
line 15. Is there anyone how can help me how solve this problem. The code i use in this example is
this:
<?php
define("MYSQL_HOST", "localhost");
define("MYSQL_USER", "root");
define("MYSQL_PASS", "mypass");
define("MYSQL_DB", "test");
$conn = mysql_connect("".MYSQL_HOST."", "".MYSQL_USER."",
"".MYSQL_PASS."") or
die(mysql_error());
mysql_select_db("".MYSQL_DB."",$conn) or die(mysql_error());
$sql = "SELECT * FROM test";
$res_value = mysql_query($sql);
//while ($field = mysql_fetch_array($res_value))
//{
$id = $field['id'];
$name = $field['name'];
echo 'ID: ' . $field['id'] . '<br />';
echo 'Name: ' . $field['name'] . '<br /><br />';
//}
?>
Please help...