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("ap pscan",$sq l);
$row=mysql_fetch_object($r esult);
if ($row){
echo ("good");
}else{
echo ("bad");
}
....
it is not working...
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("ap
$row=mysql_fetch_object($r
if ($row){
echo ("good");
}else{
echo ("bad");
}
....
it is not working...
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($resu lt);
if ($row){
echo ("good");
}else{
echo ("bad");
}
$sql="select name,passwd from user where name=$username";
$conn = mysql_connect("database", "login", "password");
$result=mysql_query($sql, $conn);
$row=mysql_fetch_row($resu
if ($row){
echo ("good");
}else{
echo ("bad");
}
ASKER
not working...
where im "telling" what is the database name?
sorry...completley new to php.
know ASP...
where im "telling" what is the database name?
sorry...completley new to php.
know ASP...
ASKER
that's the error:
Warning: Supplied argument is not a valid MySQL result resource in /home/elad/public_html/ind ex.php on line 8
8 $row=mysql_fetch_row($resu lt);
Warning: Supplied argument is not a valid MySQL result resource in /home/elad/public_html/ind
8 $row=mysql_fetch_row($resu
ASKER
that's the error:
Warning: Supplied argument is not a valid MySQL result resource in /home/elad/public_html/ind ex.php on line 8
8 $row=mysql_fetch_row($resu lt);
Warning: Supplied argument is not a valid MySQL result resource in /home/elad/public_html/ind
8 $row=mysql_fetch_row($resu
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
int mysql_db_query(string database, string query, int [link_identifier] );
try:
$row = mysql_query($query, $sql);