Jump to content

Recommended Posts

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

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. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.