Jump to content

mysql_num_rows() problam please help


redarrow

Recommended Posts

I have the varable posting from a page and the database is getting all the information from the email varable but the condition not working with the varable email now the varable email is there but the condition not working if i use name or password all works but not with email any idears please.

 

yes i have also tried the $_POST statement but no luck.

 

<?php session_start();


$db=mysql_connect("localhost","xxx","xxx");
mysql_select_db("mat_website");


$query="select email from blog_register where email='$email'";
$result=mysql_query($query);

if(mysql_num_rows($result)>1){

include("header.php");
echo "<html><body bgcolor='#ff333' vlink='blue' link='blue' alink='blue'><br><br><br><br><table align='center'><tr><td>
Sorry but username  is taken <a href='register.php'>please try again</a><br><br>Thank you.</tr></td></table></body></html>";
exit;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/37258-mysql_num_rows-problam-please-help/
Share on other sites

i dunno about your condition, but at first glance it looks like you're missin a hex in your hexidecimal bgcolor attribute.

 

also, the problem may be your query. try replacing your variable $email with a value you KNOW is in the blog_register table. if your condition isn't working, it's probably because your query isn't valid.

<?php
        session_start();

        $db = mysql_connect("localhost","xxx","xxx");
        mysql_select_db("mat_website");

        $query = "select email from blog_register where email='$email'";
        $result = mysql_query($query) OR die(mysql_error());

        $numRows = mysql_num_rows($result);
        echo "Number of results: ". $numRows ."<br />\n";

        if($numRows > 1){
        include("header.php");
        echo "<html><body bgcolor='#ff333' vlink='blue' link='blue' alink='blue'><br><br><br><br><table align='center'><tr><td>
        Sorry but username  is taken <a href='register.php'>please try again</a><br><br>Thank you.</tr></td></table></body></html>";
        exit;
        }
?>

 

that may help further diagnose the issue.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.