This code won’t work. I’ve had everything echoed and it displays fine on the webpage, as in, all the data is collected fine. What isn’t working is inserting it into the MySQL table.
This same query, without the archive insertion, works fine. But for some reason MySQL doesn’t want to insert my archive copy. The archive column exists and I’ve double checked and everything. Archive was created as ARCHIVE TEXT,. Why is this? Workaround? No error is printed.
$url = $_GET["url"];
$data = get_meta_tags($url);
echo $url = $url;
echo $tags = $data ['keywords']; // php documentation
echo $desc = $data ['description']; // a php manual
$archive = strip_tags(file_get_contents($url));
include("../library/config.php");
mysql_query("INSERT INTO URLs(url, description, tags, archive) VALUES ('$url', '$desc', '$tags', '$archive')", $link);
echo mysql_error($link);
I’m uncertain why it’s not giving you an error, because it should be! You’re taking the entire contents of an unknown URL and attempting to insert it into a table column. You should be escaping it first…
Basically, this will escape quote characters, correctly according to encoding of your table. If the mysql_connect is happening from the included ../library/config.php file, you should have this escape after that line of code, since it references the $link connection.