techiefreak05 Posted August 24, 2006 Share Posted August 24, 2006 [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?? Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 24, 2006 Share Posted August 24, 2006 you never connect to the mysql server Quote Link to comment Share on other sites More sharing options...
techiefreak05 Posted August 24, 2006 Author Share Posted August 24, 2006 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 Quote Link to comment Share on other sites More sharing options...
.josh Posted August 24, 2006 Share Posted August 24, 2006 are you sure you are actually connecting to the db? right db name, pw, etc..? Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 24, 2006 Share Posted August 24, 2006 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. Quote Link to comment Share on other sites More sharing options...
techiefreak05 Posted August 24, 2006 Author Share Posted August 24, 2006 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... Quote Link to comment Share on other sites More sharing options...
techiefreak05 Posted August 24, 2006 Author Share Posted August 24, 2006 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.