Kelvin Park wrote:
Chris wrote:
Kelvin Park wrote:
mySQL database becomes inaccessible after a buggy sql string gets queried. The SQL server runs fine, however it seems like just the database is being
looped infinitely so to say.
Here is an example:

(PHP)
$sql = "SELECT * FROM DB_TABLE WHERE PR_NUMBER = $whatever, DFLJJ =
$SD;LOOE"; (<-- invalid sql query string)
mysql_query($sql);

When this query string is queried during the (webpage) loading process, the
webpage just gets timed out without any error nor warning messages.

Does anyone know if there is a certain way to prevent mysql database from
stalling due to buggy sql strings?

use mysql_real_escape_string to stop it from happening.

I've tried the mysql_real_escape_string, however it seemed like it was working well at first, but the problem is that when I do the following query, the database crashes:

$query = "SELECT * FROM PRODUCT_TABLE WHERE MATCH (product, description) AGAINST('whatever') OR MATCH(categoryname) AGAINST('whatever')";

It seems like putting two match functions in the same query might have caused the crash.

Why are they separate? Just include another field in the first match part.

If that's not an option, union the results:

select * from table where match(product) against('whatever')
union all
select * from table where match(categoryname) against('whatever')

See http://dev.mysql.com/doc/refman/4.1/en/union.html

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to