Query Error: Newbie Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
OU_Student
Forum Newbie
Posts: 7
Joined: Tue Feb 10, 2009 5:30 pm

Query Error: Newbie Help

Post 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);

?>
sparrrow
Forum Commoner
Posts: 81
Joined: Mon Oct 20, 2008 12:22 pm

Re: Query Error: Newbie Help

Post 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);
 
?>
OU_Student
Forum Newbie
Posts: 7
Joined: Tue Feb 10, 2009 5:30 pm

Re: Query Error: Newbie Help

Post by OU_Student »

Worked great!

Thanks so much.
Post Reply