Glenskie Posted March 16, 2012 Share Posted March 16, 2012 not working :/ error reads "mysql_error() expects parameter 1 to be resource" on the line that says RIGHT HERE THIS LINE and its commented out for you... whats wrong? <?php if ($_POST["request"] == "requestFriendship") { $mem1 = preg_replace('#[^0-9]#i', '', $_POST['mem1']); $mem2 = preg_replace('#[^0-9]#i', '', $_POST['mem2']); // if (!$mem1 || !$mem2 || !$thisWipit) { echo 'Error: Missing data'; exit(); } // if ($mem1 == $mem2) { echo 'Error: You cannot add yourself as a friend'; exit(); } //See if already friends // RIGHT HERE THIS LINE $sql1 = "SELECT id FROM friends WHERE mem2='$mem1' AND mem1='$mem2' LIMIT 1"; $result1 = mysql_query($sql1) or die (mysql_error("sql1 failed")); $data1 = mysql_fetch_row($result1); if ($data1[0]) { echo 'This member is already your Friend'; exit(); } //Check if user already requested to be friends $sql2 = "SELECT id FROM friends_requests WHERE mem1='$mem1' AND mem2='$mem2' Limit 1"; $result2 = mysql_query($sql2) or die (mysql_error("sql2 failed")); $data2 = mysql_fetch_row($result2); if ($data2[0]) { echo '<img src="images/round_error.png" width="20" height="20" alt="Error" /> You have a Friend request pending for this member. Please be patient.'; exit(); } //Check if friend already requested to be friends $sql3 = "SELECT id FROM friends_requests WHERE mem1='$mem2' AND mem2='$mem1' Limit 1"; $result3 = mysql_query($sql3) or die (mysql_error("sql3 failed")); $data3 = mysql_fetch_row($result3); if ($data3[0]) { echo '<img src="images/round_error.png" width="20" height="20" alt="Error" /> This user has requested you as a Friend already! Check your Requests on your profile.'; exit(); } //If still here make insert $mem1=mysql_real_escape_string($mem1); $mem2=mysql_real_escape_string($mem2); $sql = mysql_query("INSERT INTO friends (mem1, mem2, timedate) VALUES('$mem1','$mem2',now())") or die (mysql_error("Friend Request Insertion Error")); echo '<img src="images/round_success.png" width="20" height="20" alt="Success" /> Friend request sent successfully. This member must approve the request.'; exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/259030-problem-with-code-probly-really-simple/ Share on other sites More sharing options...
Pikachu2000 Posted March 16, 2012 Share Posted March 16, 2012 Why do you have the line commented out? Of course you'll get an error when you execute a query with an empty query string . . . Quote Link to comment https://forums.phpfreaks.com/topic/259030-problem-with-code-probly-really-simple/#findComment-1327934 Share on other sites More sharing options...
Pikachu2000 Posted March 16, 2012 Share Posted March 16, 2012 Oh, wait a minute. it's mysql_error() that's complaining. mysql_error doesn't take a string as an argument, it either takes a connection resource, or no argument and it attempts to use the last connection resource that was used. Quote Link to comment https://forums.phpfreaks.com/topic/259030-problem-with-code-probly-really-simple/#findComment-1327935 Share on other sites More sharing options...
Glenskie Posted March 16, 2012 Author Share Posted March 16, 2012 im just commenting it out so you could find it... Quote Link to comment https://forums.phpfreaks.com/topic/259030-problem-with-code-probly-really-simple/#findComment-1327950 Share on other sites More sharing options...
Glenskie Posted March 16, 2012 Author Share Posted March 16, 2012 so what is the error? Quote Link to comment https://forums.phpfreaks.com/topic/259030-problem-with-code-probly-really-simple/#findComment-1327952 Share on other sites More sharing options...
PFMaBiSmAd Posted March 16, 2012 Share Posted March 16, 2012 so what is the error? Reply #2 states what is wrong with your code. Quote Link to comment https://forums.phpfreaks.com/topic/259030-problem-with-code-probly-really-simple/#findComment-1328048 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.