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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.