Jump to content

mysql_num_rows() error! plz help quick!


techiefreak05

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??
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.