contra10 Posted May 22, 2009 Share Posted May 22, 2009 Hi im trying to build a crawler and right now im trying to get information from websites and save it in my db. right now im testing on my local host and was wondering if i can access live pages. I tried to copy a wikipedia website and i got this 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 'text/javascript'>if (wgNotice != '') document.writeln(wgNotice); i was wondering if im on the right track or loss... heres my coding <?php //This code runs if the form has been submitted if (isset($_POST['submit'])) { $search = mysql_real_escape_string($_POST['search']); $data = file_get_contents("$search"); // now we insert it into the database $insert = "INSERT INTO `web` (`website`, `index`) VALUES ('$search', '$data')"; $add_web = mysql_query($insert) or die (mysql_error()); echo "$data"; ?> sucess <?php }else{ ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <h2><a href="#">Add a site</a></h2><br> <input type="text" size="35" name="search"/><br> <input type="submit" name="submit" /> </form> btw it will work for pages in my local host Quote Link to comment https://forums.phpfreaks.com/topic/159202-solved-using-file_get_contents-with-real-websites/ Share on other sites More sharing options...
fanfavorite Posted May 22, 2009 Share Posted May 22, 2009 Try mysql_real_escape_string on the two variables before they go into mysql. http://ca.php.net/mysql_real_escape_string. You will need to watch out for exploits as well, but get it working first and then worry about that. Quote Link to comment https://forums.phpfreaks.com/topic/159202-solved-using-file_get_contents-with-real-websites/#findComment-839598 Share on other sites More sharing options...
contra10 Posted May 22, 2009 Author Share Posted May 22, 2009 thxs can't believed i missed that Quote Link to comment https://forums.phpfreaks.com/topic/159202-solved-using-file_get_contents-with-real-websites/#findComment-839601 Share on other sites More sharing options...
fanfavorite Posted May 22, 2009 Share Posted May 22, 2009 We all miss things from time to time no matter how simple it may be. Quote Link to comment https://forums.phpfreaks.com/topic/159202-solved-using-file_get_contents-with-real-websites/#findComment-839614 Share on other sites More sharing options...
Maq Posted May 22, 2009 Share Posted May 22, 2009 We all miss things from time to time no matter how simple it may be. Those are usually the hardest ones to find Quote Link to comment https://forums.phpfreaks.com/topic/159202-solved-using-file_get_contents-with-real-websites/#findComment-839615 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.