Blinger1
24-03-2009, 09:20 AM
G'day everyone.
I have a quick question. This is starting to piss me off to the max :eusa_wall!!
Why doesn't this code work?
<?php
include("includes/connect.php");
$sender = $_SESSION['username'];
$reciever = "lol";
$message = $_POST['message'];
$date = date("d/m/Y");
$status = "unread";
$sql = "SELECT * FROM `members` WHERE `username`='{$reciever}'";
$query = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($query) or die(mysql_error());
echo("$num_rows");
?>
The reciever is a made up name, but that should return "0" yeah?? Well, it kinda just ends the script.
The following script works:
<?php
include("includes/connect.php");
$sender = $_SESSION['username'];
$reciever = "shane";
$message = $_POST['message'];
$date = date("d/m/Y");
$status = "unread";
$sql = "SELECT * FROM `members` WHERE `username`='{$reciever}'";
$query = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($query) or die(mysql_error());
echo("$num_rows");
?>
okay, i figured it is this part (the bold one) because if i remove that part, it runs fine..:
$num_rows = mysql_num_rows($query) or die(mysql_error());
Moved by ReviewDude (Forum Moderator) from "Web Design", this is a coding-related issue.
I have a quick question. This is starting to piss me off to the max :eusa_wall!!
Why doesn't this code work?
<?php
include("includes/connect.php");
$sender = $_SESSION['username'];
$reciever = "lol";
$message = $_POST['message'];
$date = date("d/m/Y");
$status = "unread";
$sql = "SELECT * FROM `members` WHERE `username`='{$reciever}'";
$query = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($query) or die(mysql_error());
echo("$num_rows");
?>
The reciever is a made up name, but that should return "0" yeah?? Well, it kinda just ends the script.
The following script works:
<?php
include("includes/connect.php");
$sender = $_SESSION['username'];
$reciever = "shane";
$message = $_POST['message'];
$date = date("d/m/Y");
$status = "unread";
$sql = "SELECT * FROM `members` WHERE `username`='{$reciever}'";
$query = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($query) or die(mysql_error());
echo("$num_rows");
?>
okay, i figured it is this part (the bold one) because if i remove that part, it runs fine..:
$num_rows = mysql_num_rows($query) or die(mysql_error());
Moved by ReviewDude (Forum Moderator) from "Web Design", this is a coding-related issue.