Jump to content


Photo

mysql_num_rows() error! plz help quick!


  • Please log in to reply
6 replies to this topic

#1 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 24 August 2006 - 03:59 AM

<?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>

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

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 shortener with advanced, detailed statistics:

http://tyny.us/

#2 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 24 August 2006 - 04:07 AM

you never connect to the mysql server
What is the CoronaMatrix?

#3 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 24 August 2006 - 04:08 AM

yes i did, if you read my post i said
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??

i meant i took out the DB conenct info to post on here.. but its there in the actual file
Link shortener with advanced, detailed statistics:

http://tyny.us/

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 24 August 2006 - 04:56 AM

are you sure you are actually connecting to the db? right db name, pw, etc..?
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 24 August 2006 - 05:16 AM

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.
What is the CoronaMatrix?

#6 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 24 August 2006 - 05:20 AM

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...
Link shortener with advanced, detailed statistics:

http://tyny.us/

#7 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 24 August 2006 - 05:22 AM

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
Link shortener with advanced, detailed statistics:

http://tyny.us/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users