Jump to content

A couple of mysql problems


aye

Recommended Posts

hey, im designing an RSS indexer for certain web pages. the idea is to store recently used keywords and their matches in a mysql table (the name of the table=search keyword and the matches inside the table) to speed up the search, however ive now come across two errors that i cant get rid of...
1. if a search returns many matches (~>20), the php script will exit, saying "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 <INSERT INTO values>".. is there any limit of how many mysql queries one can make under a short session and can i increase this limit somehow?
2. when searching for a word containing a number (ie 123), i get the following error "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 '123(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), link VARCHAR(50), time INT)' at line 1"

oh, and i have one more problem.. this ones not about mysql though... when searching for multiple keywords, i get the following error "Warning: fopen(<search directory>/<search query>) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /var/www/html/search.php on line 58.. that is when trying to read the rss feed from other search engines (for example feeds farm would give http://www.feedsfarm.com/s/my search&format=rss, in other words - it seems like fopen can't open path names that has spaces in them.. is there any way you can get around this?)

thanks for your help :)
Link to comment
https://forums.phpfreaks.com/topic/35869-a-couple-of-mysql-problems/
Share on other sites

genericnumber: thanks for the tip, got an other error now though: 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 '<last keyword>(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), link VARCHAR(50), tim' at line 1.

dgiberson: tried putting a space between them but there was no change :(

here's the code that inserts everything into mysql anyhow:
[code]function endElement($parser, $name) {
global $insideitem, $link, $conn, $tcount;
if ($name == "ITEM") {
if(!mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $_GET["q"] . "'")))
{
mysql_query("CREATE TABLE " . $_GET["q"] . " (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), link VARCHAR(50), time INT)",$conn) or die(mysql_error());
}
mysql_query("INSERT INTO `" . $_GET["q"] . "` (link,time) VALUES ('" . $link . "','" . time() . "')",$conn) or die(mysql_error());
$tcount++;
$link = "";
$insideitem = false;
}
}[/code]

was some time i did php, so i have probably made some newby mistake  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.