Link to home
Start Free TrialLog in
Avatar of eladr
eladr

asked on

results from db

im trying to get results from database.
i want to write "good" if the $username
variable is show in the db,and "bad"
if it isn't.
here's the code:
$sql="select name,passwd from user where name=$username";
mysql_connect("haag","elad");
$result=mysql_db_query("appscan",$sql);
$row=mysql_fetch_object($result);
if ($row){
echo ("good");
}else{
echo ("bad");
}
....

it is not working...
Avatar of us111
us111
Flag of Luxembourg image

mysql_db_query needs 3 parameters:

int mysql_db_query(string database, string query, int [link_identifier] );

try:

$row = mysql_query($query, $sql);
Oops other mistakes

$sql="select name,passwd from user where name=$username";
$conn = mysql_connect("database", "login", "password");
$result=mysql_query($sql, $conn);

$row=mysql_fetch_row($result);
if ($row){
     echo ("good");
}else{
     echo ("bad");
}
Avatar of eladr
eladr

ASKER

not working...
where im "telling" what is the database name?
sorry...completley new to php.
know ASP...
Avatar of eladr

ASKER

that's the error:
Warning: Supplied argument is not a valid MySQL result resource in /home/elad/public_html/index.php on line 8

8 $row=mysql_fetch_row($result);
Avatar of eladr

ASKER

that's the error:
Warning: Supplied argument is not a valid MySQL result resource in /home/elad/public_html/index.php on line 8

8 $row=mysql_fetch_row($result);
ASKER CERTIFIED SOLUTION
Avatar of us111
us111
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial