PDA

View Full Version : Could someone please tell me what I did wrong?


tvollmer
08-22-2002, 10:49 PM
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
That made it work!

Thank you!

Todd

Spookster
08-23-2002, 08:23 AM
You're welcome. :cool: