About Buggy SQL Query

This is a discussion on About Buggy SQL Query within the PHP General forums, part of the PHP Programming Forums category; mySQL database becomes inaccessible after a buggy sql string gets queried. The SQL server runs fine, however it seems like ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-14-2007
Kelvin Park
 
Posts: n/a
Default About Buggy SQL Query

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?

Reply With Quote
  #2 (permalink)  
Old 08-14-2007
Chris
 
Posts: n/a
Default Re: [PHP] About Buggy SQL Query

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.

--
Postgresql & php tutorials
http://www.designmagick.com/
Reply With Quote
  #3 (permalink)  
Old 08-14-2007
Kelvin Park
 
Posts: n/a
Default Re: [PHP] About Buggy SQL Query

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

Thanks, I looked over some comments posted on the PHP library web site
under mysql_real_escape_string function. I didn't realize it is also
used to aid sql injection prevention.
Reply With Quote
  #4 (permalink)  
Old 08-14-2007
Richard Lynch
 
Posts: n/a
Default Re: [PHP] About Buggy SQL Query

What is in $SD?

And are you using mysql_real_escape_string on all values?

On Mon, August 13, 2007 11:31 pm, 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?
>



--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
Reply With Quote
  #5 (permalink)  
Old 08-16-2007
Kelvin Park
 
Posts: n/a
Default Re: [PHP] About Buggy SQL Query

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.

My question is, how could I immediately just have one of my databases in
the Database Server restarted (w/o affecting any of the data)?
Reply With Quote
  #6 (permalink)  
Old 08-16-2007
Chris
 
Posts: n/a
Default Re: [PHP] About Buggy SQL Query

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/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:39 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0