Reputation: 11
<?php
session_start();
$con=mysql_connect("localhost","root","samy");
mysql_select_db("project");
if($con)
{
echo "Connected Successfully ";
}
else
{
echo "Error" . $sql . "<br>" . mysql_connect_error();
}
$name=$_SESSION['name'];
echo $name;
$sql1 = mysql_query("select cust_id from registered_user where name ='.$name.' ");
$r = mysql_num_rows($sql1);
echo $r;
$row1 = mysql_fetch_array($sql1);
$cid = $row1['cust_id'];
echo $cid;
?>
Since num_rows is returning zero therefore $cid is also not printing. Don't know what's the error;
Upvotes: 0
Views: 46
Reputation: 12039
You should remove the dot(.)
.
$sql1 = mysql_query("select cust_id from registered_user where name ='$name'");
^ ^
Also suggest to add error reporting like this
$sql1 = mysql_query("select cust_id from registered_user where name ='$name'")
or die(mysql_error());
Upvotes: 1