mandukar Posted August 6, 2012 Share Posted August 6, 2012 I'm in the process of writing up a integration tool where basically a staff member with permission clicks a link on the calender and it'll automatically post on various social networking sites such as facebook. I have hit a snag though, I get a mysql error and i'm unsure what is wrong.. The error is.. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xx/public_html/fbannounce.php on line 63 I am using the 2.0 series of smf.. I have included the php file as an attachment, please can someone help? 18785_.php Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/ Share on other sites More sharing options...
scootstah Posted August 6, 2012 Share Posted August 6, 2012 It means the query failed due to an error. Try outputting the query to make sure it is what you expect, and use mysql_error to figure out what the error is. Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367178 Share on other sites More sharing options...
mandukar Posted August 6, 2012 Author Share Posted August 6, 2012 Ahh okay thanks, I did a echo mysql_errno($link) . ": " . mysql_error($link) . "\n"; and I got the following message... 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2 tad confused does that mean I'm using something that's not compatible? Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367190 Share on other sites More sharing options...
Jessica Posted August 6, 2012 Share Posted August 6, 2012 It means your query is malformed. When you echo the error, also echo the query. Most people aren't going to download your whole file, just post the relevant code and the query. Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367210 Share on other sites More sharing options...
mandukar Posted August 6, 2012 Author Share Posted August 6, 2012 The back code... <? function containsTLD($string) { preg_match( "/(AC($|\/)|\.AD($|\/)|\.AE($|\/)|\.AERO($|\/)|\.AF($|\/)|\.AG($|\/)|\.AI($|\/)|\.AL($|\/)|\.AM($|\/)|\.AN($|\/)|\.AO($|\/)|\.AQ($|\/)|\.AR($|\/)|\.ARPA($|\/)|\.AS($|\/)|\.ASIA($|\/)|\.AT($|\/)|\.AU($|\/)|\.AW($|\/)|\.AX($|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.SN($|\/)|\.SO($|\/)|\.SR($|\/)|\.ST($|\/)|\.SU($|\/)|\.SV($|\/)|\.SY($|\/)|\.SZ($|\/)|\.TC($|\/)|\.TD($|\/)|\.TEL($|\/)|\.TF($|\/)|\.TG($|\/)|\.TH($|\/)|\.TJ($|\/)|\.TK($|\/)|\.TL($|\/)|\.TM($|\/)|\.TN($|\/)|\.TO($|\/)|\.TP($|\/)|\.TR($|\/)|\.TRAVEL($|\/)|\.TT($|\/)|\.TV($|\/)|\.TW($|\/)|\.TZ($|\/)|\.UA($|\/)|\.UG($|\/)|\.UK($|\/)|\.US($|\/)|\.UY($|\/)|\.UZ($|\/)|\.VA($|\/)|\.VC($|\/)|\.VE($|\/)|\.VG($|\/)|\.VI($|\/)|\.VN($|\/)|\.VU($|\/)|\.WF($|\/)|\.WS($|\/)|\.XN--0ZWM56D($|\/)|\.XN--11B5BS3A9AJ6G($|\/)|\.XN--80AKHBYKNJ4F($|\/)|\.XN--9T4B11YI5A($|\/)|\.XN--DEBA0AD($|\/)|\.XN--G6W251D($|\/)|\.XN--HGBK6AJ7F53BBA($|\/)|\.XN--HLCJ6AYA9ESC7A($|\/)|\.XN--JXALPDLP($|\/)|\.XN--KGBECHTV($|\/)|\.XN--ZCKZAH($|\/)|\.YE($|\/)|\.YT($|\/)|\.YU($|\/)|\.ZA($|\/)|\.ZM($|\/)|\.ZW)/i", $string, $M); $has_tld = (count($M) > 0) ? true : false; return $has_tld; } function cleaner($url) { $U = explode(' ',$url); $W =array(); foreach ($U as $k => $u) { if (stristr($u,".")) { //only preg_match if there is a dot if (containsTLD($u) === true) { unset($U[$k]); return cleaner( implode(' ',$U)); } } } return str_replace(array('[img=',']','<br /><br />'), array('','','/n'), implode(' ',$U)); } function fbtext($string){ $start="[b]"; $end="[/b]"; cleaner($string); $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } if(!$_POST['page']){ ########## Database Info ########## $db_server = 'localhost'; $db_name = 'dumb_trans'; $db_user = 'dumb_trans'; $db_passwd = 'dumb'; $link = mysql_connect($db_server, $db_name, $db_passwd); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db($db_name,$link); $topic_id = $_GET['topic_id']; $date = $_GET['date']; $type = $_GET['type']; $sql = "SELECT * FROM `smf_topics` LEFT JOIN `smf_messages` ON `smf_topics`.`id_first_msg` = `smf_messages`.`id_msg` WHERE `smf_topics`.`id_topic`=".$topic_id ; $result = mysql_query($sql); $row = mysql_fetch_array($result); echo mysql_errno($link) . ": " . mysql_error($link) . "\n"; }else{ // if form is submitted post to the group $group_grp = $_POST['group']; $to_grp = 'gruup@groups.facebook.com'; $subject_grp = ''; $message_grp = $group_grp; $headers_grp = 'From: email@hotmail.co.uk' . "\r\n" . 'Reply-To: email@hotmail.co.uk' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to_grp, $subject_grp, $message_grp, $headers_grp); } ?> Then the form part <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <? if(!$_POST['page']){ ?> <form action="fbannounce.php" method="post"> <strong>Facebook Group Post:</strong> <br /> <br /> <textarea name="group" cols="60" rows="15"> <? echo $type." - ". date("D jS M", strtotime($date))." - ".$row['subject']; echo " "; echo str_replace("<br />","\n",fbtext($row['body'])); echo " "; echo "http://url.com/smf/index.php?topic=".$topic_id.".0"; ?> </textarea> <br /> <br /> <strong>Facebook Page Post:</strong> <br /> <br /> <textarea name="page" cols="60" rows="15"> <? echo $type." - ". date("D jS M", strtotime($date))." - ".$row['subject']; echo " "; echo "http://url.com/smf/index.php?topic=".$topic_id.".0"; ?> </textarea> <input type="submit" name="post" value="submit" /> </form> <? } else { ?> <strong>Status Updates updated check below for output - profile page might come in 10 minutes late:</strong> <br /> <br /> <strong>Group:</strong><a href="http://www.facebook.com/groups/group/" target="_blank">http://www.facebook.com/groups/gruop/</a> <br /> <br /> <br /> <strong>Want to send a group marketing message? <a href="fbgroupmarketing.php">Click here</a></strong> <? } ?> </body> </html> <? if(!$_POST['page']){ mysql_close($link); }?> Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367227 Share on other sites More sharing options...
mandukar Posted August 6, 2012 Author Share Posted August 6, 2012 its basicly in two parts, the first part is the php script then the 2nd part is the form. Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367228 Share on other sites More sharing options...
Christian F. Posted August 7, 2012 Share Posted August 7, 2012 I'd have a second look at where you're fetching the user-input, and keep in mind that you're using POST to send the data. Also, you really need to use input validation to ensure that the data you're receiving is correct, plus output escaping1. As you're now you're wide open for attacks, in the form of SQL injections, HTML injections and e-mail header injections. PS: There is absolutely no need to close the MySQL connection, PHP handles that just fine on its own. 1mysql_real_escape_string (), quote_smart (), or Prepared Statements for SQL, htmlspecialchars () for HTML, and addslashes () for e-mail headers. However, without proper input validation you're still not safe. Especially in the case of e-mail headers. Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367417 Share on other sites More sharing options...
scootstah Posted August 7, 2012 Share Posted August 7, 2012 and addslashes () for e-mail headers. I don't think addslashes() is adequate enough to sanitize email headers. You need to strip the line-feed character, which could be hex encoded (0x0A). Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367447 Share on other sites More sharing options...
mandukar Posted August 7, 2012 Author Share Posted August 7, 2012 Thanks guys, I found out that i should also be adding the data structore e.g. smf_topics.id_msg instead of `id_msg` WHERE `smf_topics is that correct in me thinking that? Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367476 Share on other sites More sharing options...
Christian F. Posted August 7, 2012 Share Posted August 7, 2012 scootstah: Thus the last line of my post. Mandukar: You can add the table name to the column definition, yes. This will prevent the SQL engine from becoming confused, if you join two (or more) tables which have the same column name in them. So while it might be a good idea in this situation, it is not the solution to the problem you posted about in your original post. Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367501 Share on other sites More sharing options...
mandukar Posted August 7, 2012 Author Share Posted August 7, 2012 yeah, i'm not entirely sure how to correct it, i don't suppose you or someone could start me off? please Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367508 Share on other sites More sharing options...
Christian F. Posted August 7, 2012 Share Posted August 7, 2012 I gave you a rather big hint on what to look for in my first post of this thread, I suggest re-reading it and paying attention to the details. Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367511 Share on other sites More sharing options...
mandukar Posted August 7, 2012 Author Share Posted August 7, 2012 okay I got it working kind of, the info is now being displayed in the form but the actural submit button isn't working lmao Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367517 Share on other sites More sharing options...
Christian F. Posted August 7, 2012 Share Posted August 7, 2012 What does the updated code look like? Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367518 Share on other sites More sharing options...
mandukar Posted August 7, 2012 Author Share Posted August 7, 2012 <? function containsTLD($string) { preg_match( "/(AC($|\/)|\.AD($|\/)|\.AE($|\/)|\.AERO($|\/)|\.AF($|\/)|\.AG($|\/)|\.AI($|\/)|\.AL($|\/)|\.AM($|\/)|\.AN($|\/)|\.AO($|\/)|\.AQ($|\/)|\.AR($|\/)|\.ARPA($|\/)|\.AS($|\/)|\.ASIA($|\/)|\.AT($|\/)|\.AU($|\/)|\.AW($|\/)|\.AX($|\/)|\.AZ($|\/)|\.BA($|\/)|\.BB($|\/)|\.BD($|\/)|\.BE($|\/)|\.BF($|\/)|\.BG($|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SZ($|\/)|\.TC($|\/)|\.TD($|\/)|\.TEL($|\/)|\.TF($|\/)|\.TG($|\/)|\.TH($|\/)|\.TJ($|\/)|\.TK($|\/)|\.TL($|\/)|\.TM($|\/)|\.TN($|\/)|\.TO($|\/)|\.TP($|\/)|\.TR($|\/)|\.TRAVEL($|\/)|\.TT($|\/)|\.TV($|\/)|\.TW($|\/)|\.TZ($|\/)|\.UA($|\/)|\.UG($|\/)|\.UK($|\/)|\.US($|\/)|\.UY($|\/)|\.UZ($|\/)|\.VA($|\/)|\.VC($|\/)|\.VE($|\/)|\.VG($|\/)|\.VI($|\/)|\.VN($|\/)|\.VU($|\/)|\.WF($|\/)|\.WS($|\/)|\.XN--0ZWM56D($|\/)|\.XN--11B5BS3A9AJ6G($|\/)|\.XN--80AKHBYKNJ4F($|\/)|\.XN--9T4B11YI5A($|\/)|\.XN--DEBA0AD($|\/)|\.XN--G6W251D($|\/)|\.XN--HGBK6AJ7F53BBA($|\/)|\.XN--HLCJ6AYA9ESC7A($|\/)|\.XN--JXALPDLP($|\/)|\.XN--KGBECHTV($|\/)|\.XN--ZCKZAH($|\/)|\.YE($|\/)|\.YT($|\/)|\.YU($|\/)|\.ZA($|\/)|\.ZM($|\/)|\.ZW)/i", $string, $M); $has_tld = (count($M) > 0) ? true : false; return $has_tld; } function cleaner($url) { $U = explode(' ',$url); $W =array(); foreach ($U as $k => $u) { if (stristr($u,".")) { //only preg_match if there is a dot if (containsTLD($u) === true) { unset($U[$k]); return cleaner( implode(' ',$U)); } } } return str_replace(array('[img=',']','<br /><br />'), array('','','/n'), implode(' ',$U)); } function fbtext($string){ $start="[b]"; $end="[/b]"; cleaner($string); $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } if(!$_POST['page']){ ########## Database Info ########## $db_server = 'localhost'; $db_name = 'test_trans'; $db_user = 'test_trans'; $db_passwd = 'testr'; $link = mysql_connect($db_server, $db_name, $db_passwd); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db($db_name,$link); $topic_id = $_GET['topic_id']; $date = $_GET['date']; $type = $_GET['type']; $sql = mysql_query("SELECT DATE_FORMAT(smf_calendar.startDate, '%W <br>%D %M %y') AS startDate, smf_calendar.ID_TOPIC, smf_topics.ID_FIRST_MSG, smf_messages.subject, CURDATE() FROM smf_calendar INNER JOIN smf_topics ON smf_calendar.ID_TOPIC=smf_topics.ID_TOPIC INNER JOIN smf_messages ON smf_topics.ID_FIRST_MSG=smf_messages.ID_MSG WHERE smf_calendar.startDate >= CURDATE() AND smf_calendar.startDate <= DATE_ADD(curdate(), INTERVAL 1 MONTH) ORDER BY smf_calendar.startDate ASC"); // if form is submitted post to the group $group_grp = $_POST['group']; $to_grp = 'test@groups.facebook.com'; $subject_grp = ''; $message_grp = $group_grp; $headers_grp = 'From: test@hotmail.co.uk' . "\r\n" . 'Reply-To: test@hotmail.co.uk' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to_grp, $subject_grp, $message_grp, $headers_grp); } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <? if(!$_POST['page']){ ?> <form action="fbannounce.php" method="post"> <strong>Facebook Group Post:</strong> <br /> <br /> <textarea name="group" cols="60" rows="15"> <? echo $type." - ". date("D jS M", strtotime($date))." - ".$row['subject']; echo " "; echo str_replace("<br />","\n",fbtext($row['body'])); echo " "; while($row = mysql_fetch_array($sql)) { echo "<tr height='40'><td width='100'>".$row['startDate']."</td><td><a href='http://test.com/smf/index.php?topic=".$row['ID_TOPIC']."'>" . $row['subject'] . "</a></td></tr>"; } ?> </textarea> <br /> <input type="submit" name="post" value="submit" /> </form> <? } else { ?> <strong>Status Updates updated check below for output - profile page might come in 10 minutes late:</strong> <br /> <br /> <strong>Group:</strong><a href="http://www.facebook.com/groups/test/" target="_blank">http://www.facebook.com/groups/test/</a> <br /> <br /> <br /> <strong>Want to send a group marketing message? <a href="fbgroupmarketing.php">Click here</a></strong> <? } ?> </body> </html> <? if(!$_POST['page']){ mysql_close($link); }?> Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367521 Share on other sites More sharing options...
scootstah Posted August 7, 2012 Share Posted August 7, 2012 You have malformed HTML. You can't put table elements inside a textarea, and beyond that you don't even have <table></table>. EDIT: Actually, scratch that... I suppose you may have wanted the HTML as text, rather than markup. For clarification, what do you mean by the button "isn't working"? Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367523 Share on other sites More sharing options...
mandukar Posted August 7, 2012 Author Share Posted August 7, 2012 erm yeah, basicly i just want it as text displaed in the box basicly when u hit the submit button it should of sent the info in the text box to whevere the script wants it to go to, but at the moment pressing submit wont do anything lol Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367525 Share on other sites More sharing options...
mandukar Posted August 7, 2012 Author Share Posted August 7, 2012 okay, i got the form sorted, i hit submit and it goes to the next part, but the contents of the textarea isn't being sent to the group still.. any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367530 Share on other sites More sharing options...
Christian F. Posted August 7, 2012 Share Posted August 7, 2012 You need to escape HTML code if you want to display it in a textarea. htmlspecialchars () should do the trick for you. I recommend reading the PHP manual for more information on it. Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367535 Share on other sites More sharing options...
mandukar Posted August 7, 2012 Author Share Posted August 7, 2012 yeah, i already have the text displayed, like i said, the problem now is its not sending the info to the facebook group :S.. Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367537 Share on other sites More sharing options...
scootstah Posted August 7, 2012 Share Posted August 7, 2012 So, what exactly is happening? Is the email being sent, but not with the expected data? Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367553 Share on other sites More sharing options...
mandukar Posted August 7, 2012 Author Share Posted August 7, 2012 well, the page comes as a result with the bit at the bottom asuming the script is working, but nothing is being displayed on the facebook group page.. Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367557 Share on other sites More sharing options...
scootstah Posted August 7, 2012 Share Posted August 7, 2012 $to_grp = 'gruup@groups.facebook.com'; Could it be this line? It looks like "group" is misspelled. Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367561 Share on other sites More sharing options...
mandukar Posted August 7, 2012 Author Share Posted August 7, 2012 yeah, i put it like that for the sake of putting it on here, don't want my details being public lol.. but in the code it has the group email address.. Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367564 Share on other sites More sharing options...
scootstah Posted August 7, 2012 Share Posted August 7, 2012 }else{ // if form is submitted post to the group $group_grp = $_POST['group']; $to_grp = 'gruup@groups.facebook.com'; $subject_grp = ''; $message_grp = $group_grp; $headers_grp = 'From: email@hotmail.co.uk' . "\r\n" . 'Reply-To: email@hotmail.co.uk' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to_grp, $subject_grp, $message_grp, $headers_grp); } Have you made sure this block of code is executing? And have you made sure the mail() function is returning true? Quote Link to comment https://forums.phpfreaks.com/topic/266737-facebook-intergration-with-smf-20-series/#findComment-1367567 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.