Page 1 of 1

Query Error: Newbie Help

Posted: Sun Feb 15, 2009 1:41 pm
by OU_Student
Hello,

I'm new to PHP and I can't figure this error out for the life of me.

[15-Feb-2009 11:35:37] PHP Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource on line 8.
##################################################

Any help would be appreciated!

<?php

$dbc = mysql_connect('localhost','username','password');

$query = 'SELECT * FROM Users';


$result = mysql_query($dbc,$query) or die(mysql_error());

while($row = mysql_fetch_array($result))
{
$checkEmail = $row['email'];
echo $checkEmail;
}

mysql_close($dbc);

?>

Re: Query Error: Newbie Help

Posted: Sun Feb 15, 2009 1:58 pm
by sparrrow

Code: Select all

<?php
 
$dbc = mysql_connect('localhost','username','password');
[color=#FF0000][b]$Link = mysql_select_db('mydatabase');[/b][/color] //Select a database!
$query = 'SELECT * FROM Users'; 
 
 
[color=#FF0000][b]$result = mysql_query($query) or die(mysql_error());[/b][/color]  //Omit db or link reference and just pass query. It will assume last db and link used.
 
while($row = mysql_fetch_array($result))
{
$checkEmail = $row['email'];
echo $checkEmail;
}
 
mysql_close($dbc);
 
?>

Re: Query Error: Newbie Help

Posted: Sun Feb 15, 2009 2:05 pm
by OU_Student
Worked great!

Thanks so much.