Jump to content

Archived

This topic is now archived and is closed to further replies.

techiefreak05

mysql_num_rows() error! plz help quick!

Recommended Posts

[code]<?php
function userExists($a){
  global $conn;
  $q = "select username from users where username = '$a'";
  $result = mysql_query($q,$conn);
  return (mysql_num_rows($result) > 0);
}

if($_POST['sendMess']){
$to = $_POST['to'];
$from = $_SESSION['username'];
$message = $_POST['message'];
$subject = $_POST['subject'];
$date = date("D M j G:i:s T Y");

  if(userExists($_POST['to'])){
echo "<font color=red>Your Message has been sent!</font>";
mysql_query("INSERT INTO `messages` ( `from` , `to` , `message` , `date` , `status` , `subject`)
VALUES ('$from', '$to', '$message', '$date', 'no', '$subject');") or die("There was an error sending your message");
mysql_query("INSERT INTO `outbox` ( `from` , `to` , `message` , `date` , `status` , `subject`)
VALUES ('$from', '$to', '$message', '$date', 'no', '$subject');") or die(mysql_error());
}else{
echo "<font color=red>That Username does not exist! Your message has not been sent</font>";
}
}
?>
<form action="" method="post">
      <table align="center" border="0" cellspacing="0" cellpadding="3">
<tr><td bgcolor="#66CCCC"><font color=black>To:</font></td><td bgcolor="#6699CC"><input type="text" name="to" size="35"></td></tr>
<tr><td bgcolor="#66CCCC"><font color=black>Subject:</font></td><td bgcolor="#6699CC"><input type="text" name="subject" size="35"></td></tr>
<tr><td bgcolor="#66CCCC"><font color=black>Message:</font></td><td bgcolor="#6699CC"><textarea name="message" rows="10" cols="55"></textarea></td></tr>
<tr><td colspan="2" align="right"><input type="submit" name="sendMess" value="-Send Message-"></td></tr>
</table>
</form>[/code]

thats my form and php code to send a message, well my friends but when he tried it.. it says
[code]Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/www/flamelicker.com/newsite/login/sendMessage.php on line 15 [/code]

it wont be line 15, cuz there is no mysql_num_rows on that line and i took out the DB conenct stuff.. so why is it getting that error??

Share this post


Link to post
Share on other sites
yes i did, if you read my post i said [code]it wont be line 15, cuz there is no mysql_num_rows on that line and [b]i took out the DB conenct stuff[/b].. so why is it getting that error??[/code]

i meant i took out the DB conenct info to post on here.. but its there in the actual file

Share this post


Link to post
Share on other sites
how do you know it's mysql_num_rows()? Could you please give us your error and not your friend's? That doesn't help us any.  The error is misguiding since it's your friend who got the error not you.

Share this post


Link to post
Share on other sites
ok, i have the EXACT same code as he does..and it works just fine! and yes, i get the same error as he does when i go to his page... so idk what could be wrong...

Share this post


Link to post
Share on other sites
oh duh, the error i first posted is a mysql_query error! haha well its both a query and num_rows error.. they both say the same thing

Share this post


Link to post
Share on other sites

×

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.