benroles
07-02-2004, 06:51 PM
Hello,
I know what I am doing (I think!) in PHP but I am having real problems reading the VB3_ tables... This code should check if the username exists in the database, but I cannot get it to work. Can anyone please tell me why?
$query = "SELECT * from vb3_user where 1 and username like '$username'";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
echo $rows; //JUST A TEMPORARY THING FOR TESTING
if ($rows>0){
echo('<p><strong><font color="#FF0000">! The username you selected is already being used. Please select another.</font></strong></p>');
}
Please note that I already called a connection to the database in an include:
$db = mysql_connect("localhost","xxxxx","xxxxx");
mysql_select_db("xxxxx",$db);
When I run this script on another table I get back the number of rows through the echo command, but on the vb3_user table I get nothing, not even an 'echo' of $rows (which should be 1 or 0).
PLEASE can somebody explain what the hell is happening?!!
Regards,
Ben.
I know what I am doing (I think!) in PHP but I am having real problems reading the VB3_ tables... This code should check if the username exists in the database, but I cannot get it to work. Can anyone please tell me why?
$query = "SELECT * from vb3_user where 1 and username like '$username'";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
echo $rows; //JUST A TEMPORARY THING FOR TESTING
if ($rows>0){
echo('<p><strong><font color="#FF0000">! The username you selected is already being used. Please select another.</font></strong></p>');
}
Please note that I already called a connection to the database in an include:
$db = mysql_connect("localhost","xxxxx","xxxxx");
mysql_select_db("xxxxx",$db);
When I run this script on another table I get back the number of rows through the echo command, but on the vb3_user table I get nothing, not even an 'echo' of $rows (which should be 1 or 0).
PLEASE can somebody explain what the hell is happening?!!
Regards,
Ben.