Daok
Apr 27th, 2003, 06:13 PM
Hello
I am new to php and I wanted to know how to show all the value of my table. I am using mysql.
Here is my code:
<?
// db variables
// inserts variables accordingly
$host = "misterp2d.dyndns.org";
$user = "bye";
$pass = "allo";
$db = "Jeux";
$table = "Usager";
// connecting to the db
$link = mysql_connect ($host, $user, $pass)
or die("Impossible de se connecter : " . mysql_error());
// the db query
$q = "SELECT * from $table";
$results = mysql_select_db ($db);
// fetching the results
$result = mysql_query("SELECT id_Usager, name_Usager FROM Usager");
while ($row = mysql_fetch_array($result))
{
printf ("ID: %s Name: %s", $row[0], $row[1]);
}
mysql_free_result($result);
// closing the db link
mysql_close ($link);
?>
Here is the errors I got:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp\www\test.php on line 29
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp\www\test.php on line 34
I am new to php and I wanted to know how to show all the value of my table. I am using mysql.
Here is my code:
<?
// db variables
// inserts variables accordingly
$host = "misterp2d.dyndns.org";
$user = "bye";
$pass = "allo";
$db = "Jeux";
$table = "Usager";
// connecting to the db
$link = mysql_connect ($host, $user, $pass)
or die("Impossible de se connecter : " . mysql_error());
// the db query
$q = "SELECT * from $table";
$results = mysql_select_db ($db);
// fetching the results
$result = mysql_query("SELECT id_Usager, name_Usager FROM Usager");
while ($row = mysql_fetch_array($result))
{
printf ("ID: %s Name: %s", $row[0], $row[1]);
}
mysql_free_result($result);
// closing the db link
mysql_close ($link);
?>
Here is the errors I got:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp\www\test.php on line 29
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp\www\test.php on line 34