So basically I have a input box and the user pastes his link in for example http://www.yahoo.com and I use file_get_contents to download the html and store it in the variable, $html
The problem is that it works off and on and I am pretty sure it has to deal with the data file_get_contents downloads. I tried http://www.mail.com and it worked. Then I tried many other links and it complains. For example: http://www.phpbuilder.net will give me the following message:
Warning: pg_query(): Query failed: ERROR: syntax error at or near "http" at character 3959 in /home/hkhalid/public_html/yoshta/login.php on line 54
Line 54 is: $result = pg_query($query);
Why does it work with certain links? All I am telling it to do is get the html and store it in variable.
Here is the snippet:
if ($_POST['add']){
$link = $_POST['link'];
if (strlen($link) > 100){
msgred("The max legnth of the link is 100 characters");
}else{
$html = file_get_contents($link);
$query = "INSERT INTO posts (uid, link, html) VALUES ('$uid','$link','$html')";
$result = pg_query($query);
//echo $query;
}
}