1. Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as:

    All that and more! Registration is quick, simple and absolutely free. Join our community today!

PHP Help!!! project

Discussion in 'Coding, Programming' started by lambutan, Aug 19, 2016.

  1. lambutan

    lambutan Enthusiast Established

    warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/u641301104/public_html/ch-ro-pr/submit.php on line 18



    eto po ung code















    <?php
    require('includes/config.php');

    $dbactive = $row['active'];
    $user = $_post['user'];
    $enroll = $_post['enroll'];
    $pass = $_post['pass'];
    $re_pass = $_post['re-pass'];

    if($user=="" || $pass=="" || $re_pass == "" || $enroll == "" )
    header('location:reg.php?err=0');
    // echo $user." ".$pass." ".$re_pass
    else
    if($pass!=$re_pass)
    header('location:reg.php?err=1');
    else {
    $sql = "select null from stud_data where usr_name='".$user."' or usr_roll='".$enroll."'";
    $result=mysql_query($sql);
    if ($result==false)
    {
    die(mysql_error());
    }
    $count = mysql_num_rows($result);
    if($count>0)
    header('location:reg.php?err=2');
    else {
    $pass = md5("5".$pass."@");
    $sql = "insert into stud_data (usr_name,usr_roll,usr_pass) values('".$user."','".$enroll."','".$pass."')";
    mysql_query($sql);
    echo "registered successfully, <a href='index.php'>login</a>";
    }
    }
    ?>
     
  2. Scizcka

    Scizcka Honorary Poster Established

    Okay, and then what?
     
  3. try mo maginsert ng
    var_dump($result);
    at pag boolean po yung result dapat "===" yung operators not "==" lang o kaya pwede naman "!$result" para sa false

    <?php
    require('includes/config.php');

    $dbactive = $row['active'];
    $user = $_post['user'];
    $enroll = $_post['enroll'];
    $pass = $_post['pass'];
    $re_pass = $_post['re-pass'];

    if($user=="" || $pass=="" || $re_pass == "" || $enroll == "" )
    header('location:reg.php?err=0');
    // echo $user." ".$pass." ".$re_pass
    else
    if($pass!=$re_pass)
    header('location:reg.php?err=1');
    else {
    $sql = "select null from stud_data where usr_name='".$user."' or usr_roll='".$enroll."'";
    $result=mysql_query($sql);


    /////////////////
    var_dump($result);///tignan mo kung ano yung output, di kasi namin alam kung ano laman ng database mo so need natin ng debug info
    ////////////////////

    if ($result==false)
    {
    die(mysql_error());
    }
    $count = mysql_num_rows($result);
    if($count>0)
    header('location:reg.php?err=2');
    else {
    $pass = md5("5".$pass."@");
    $sql = "insert into stud_data (usr_name,usr_roll,usr_pass) values('".$user."','".$enroll."','".$pass."')";
    mysql_query($sql);
    echo "registered successfully, <a href='index.php'>login</a>";
    }
    }
    ?>
     
  4. jokerger25

    jokerger25 Enthusiast Established

    Try mo mag echo ng mysql_error() para makita mo kung saan ang error.
    Sa tingin ko yang "SELECT null" ang error mo..
     
Tags / Keywords: