What's new

Closed Help!!! project

Status
Not open for further replies.

lambutan

Honorary Poster
Joined
Nov 3, 2015
Posts
119
Reaction
272
Points
136
Age
29
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>";
}
}
?>
 
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>";
}
}
?>
 
Try mo mag echo ng mysql_error() para makita mo kung saan ang error.
Sa tingin ko yang "SELECT null" ang error mo..
 
Status
Not open for further replies.

Similar threads

Back
Top