CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   MySQL (http://www.codingforums.com/forumdisplay.php?f=7)
-   -   Could someone please tell me what I did wrong? (http://www.codingforums.com/showthread.php?t=4663)

tvollmer 08-22-2002 10:49 PM

Could someone please tell me what I did wrong?
 
Here is a script I have started working on.
My web host uses PHP 4.2.2 and MySql 3.23.51

<?

// Database Variables

$server = "localhost";
$database = "tsdbase";
$username = "frank";
$password = "chicken";
$table = "names";

// Connect to Database

$db = mysql_connect($server,$username,$password,$database);

$res = mysql_query("SELECT * FROM $table", $db);

$data = mysql_fetch_array($res);

?>

When I run the script, I get the following error :

"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource"

What am I doing wrong?
All I want to do is to open a database and display a table to the browser.

Todd

Spookster 08-22-2002 10:59 PM

<?

// Database Variables

$server = "localhost";
$database = "tsdbase";
$username = "frank";
$password = "chicken";
$table = "names";

// Connect to Database

$dbcnx = @mysql_connect($server,$username,$password) or die ("Database Connection Error");

$dbhandle = mysql_select_db($database, $dbcnx);

$res = mysql_query("SELECT * FROM '$table'", $dbhandle);

$data = mysql_fetch_array($res);

?>

tvollmer 08-23-2002 01:13 AM

Thanks
 
That made it work!

Thank you!

Todd

Spookster 08-23-2002 08:23 AM

You're welcome. :cool:


All times are GMT +1. The time now is 04:58 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.