RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-09 Thread Michael Rudel

Hi Mark,

... beside of what was mentioned be4, you have also
a logical error in the way you append to your $sql-
query in the while loop.

Look: letz say, $find is "The Fields of the Nephilim",
so your $wordsarray would be:

0 ==> The
1 ==> Fields
2 ==> of
3 ==> the
4 ==> Nephilim

in your while-loop, you append every array-entry to
your $sql with "$word)".

So your whole SQL-Statement would read:

"SELECT bandname FROM bands WHERE (bandname LIKE The)Fields)of)the)Nephilim)"

This statement will result in error !

Try this 1:

/
//$find is text box input
$wordsarray = explode(" ",$find);

$sql = "SELECT bandname FROM bands WHERE bandname <> ''";

while ( list( $key, $word ) = each( $wordsarray ) )
{ 
   $sql .= " OR bandname like '%".$word."%'";
}
echo $sql."";

$queryResult = mysql_query($sql);

while ( $myrow = mysql_fetch_assoc( $queryResult ) )
{
   echo " ".$myrow["bandname"]." "."\n";
}
/

Hope this helps ;)

Greetinx,
  Mike

Michael Rudel 
- Web-Development, Systemadministration -

Besuchen Sie uns am 20. und 21. August 2001 auf der
online-marketing-düsseldorf in Halle 1 Stand E 16
___

Suchtreffer AG 
Bleicherstraße 20 
D-78467 Konstanz 
Germany 
fon: +49-(0)7531-89207-17 
fax: +49-(0)7531-89207-13 
e-mail: mailto:[EMAIL PROTECTED] 
internet: http://www.suchtreffer.de 
___ 



> -Original Message-
> From: Mark Gordon [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 09, 2001 1:54 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Dynamic SQL + result resource error
> 
> 
> Why is this code generating an error when it outputs a
> valid SQL statement?  (there are no parse errors)
> 
> //$find is text box input
> $wordsarray = explode(" ",$find); 
> $sql = "SELECT bandname FROM bands WHERE (bandname
> LIKE ";
> $i = 0;
> while ($i < count($wordsarray)) 
> { 
> $word = current($wordsarray); 
> next($wordsarray);
> $sql=$sql."$word)";
> $i++; 
> }
> print "$sql";
> while ($myrow=mysql_fetch_row($sql))
> {
> print "$myrow[0],";
> }
> 
> =
> Mark
> [EMAIL PROTECTED]
> 
> __
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: 
> [EMAIL PROTECTED]
> 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-08 Thread Mats Remman

Look at this snippet :
> $word = current($wordsarray); 
> next($wordsarray);
> $sql=$sql."$word)";

if you have 2 words the sql would extend to
word1)word2) .. this is invalid sql syntax.

Change the 
while ($i < count($wordsarray)) 
{ 
$word = current($wordsarray); 
next($wordsarray);
$sql=$sql."$word)";
$i++; 
}
bit into something like this
$sep = "";
foreach( $wordsarray as $v ) {
$sql .= $sep." $word ";
$sep = " OR band LIKE ";
}
$sql .= ")";

Then retry the queries.

oh and yes, include the mysql_query() as Mark Gordon mentioned.


Mats Remman
PHP Developer/Mysql DBA
Coretrek, Norway
+47 51978597 / +47 916 23566

 

> -Original Message-
> From: Matthew Loff [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 09, 2001 2:20 AM
> To: 'Ben Bleything'; 'Mark Gordon'; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Dynamic SQL + result resource error
> 
> 
> 
> Ha ha... I should have meantioned "Here's what it -should- be" or
> something of the like. :)
> 
> I suspect that was the only problem with his code, but perhaps there's
> something else there.
> 
> 
> -Original Message-----
> From: Ben Bleything [mailto:[EMAIL PROTECTED]] 
> Sent: Sunday, July 08, 2001 8:13 PM
> To: 'Matthew Loff'; 'Mark Gordon'; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Dynamic SQL + result resource error
> 
> 
> Guess I'm just a big dumbass then, aren't I =P
> 
> Oops.
> 
> I suppose that would cause it to fail then, wouldn't it?
> 
> =>  Ben
> 
> -Original Message-
> From: Matthew Loff [mailto:[EMAIL PROTECTED]] 
> Sent: Sunday, July 08, 2001 5:10 PM
> To: 'Ben Bleything'; 'Mark Gordon'; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Dynamic SQL + result resource error
> 
> 
> The code you're referencing is my modification of his original post. :)
> 
> 
> -Original Message-
> From: Ben Bleything [mailto:[EMAIL PROTECTED]] 
> Sent: Sunday, July 08, 2001 8:04 PM
> To: 'Matthew Loff'; 'Mark Gordon'; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Dynamic SQL + result resource error
> 
> 
> Sure he is.  Right here:
> 
> $queryResult = mysql_query($sql);
> 
> what exact error is occurring?
> 
> -Original Message-
> From: Matthew Loff [mailto:[EMAIL PROTECTED]] 
> Sent: Sunday, July 08, 2001 5:00 PM
> To: 'Mark Gordon'; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Dynamic SQL + result resource error
> 
> 
> You aren't calling mysql_query() to execute the query.
> 
> //$find is text box input
> $wordsarray = explode(" ",$find); 
> $sql = "SELECT bandname FROM bands WHERE (bandname
> LIKE ";
> $i = 0;
> while ($i < count($wordsarray)) 
> { 
> $word = current($wordsarray); 
> next($wordsarray);
> $sql=$sql."$word)";
> $i++; 
> }
> print "$sql";
> 
> $queryResult = mysql_query($sql);
> 
> while ($myrow=mysql_fetch_row($queryResult))
> {
> print "$myrow[0],";
> }
> 
> 
> -Original Message-
> From: Mark Gordon [mailto:[EMAIL PROTECTED]] 
> Sent: Sunday, July 08, 2001 7:54 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Dynamic SQL + result resource error
> 
> 
> Why is this code generating an error when it outputs a
> valid SQL statement?  (there are no parse errors)
> 
> //$find is text box input
> $wordsarray = explode(" ",$find); 
> $sql = "SELECT bandname FROM bands WHERE (bandname
> LIKE ";
> $i = 0;
> while ($i < count($wordsarray)) 
> { 
> $word = current($wordsarray); 
> next($wordsarray);
> $sql=$sql."$word)";
> $i++; 
> }
> print "$sql";
> while ($myrow=mysql_fetch_row($sql))
> {
> print "$myrow[0],";
> }
> 
> =
> Mark
> [EMAIL PROTECTED]
> 
> __
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-08 Thread Matthew Loff


Ha ha... I should have meantioned "Here's what it -should- be" or
something of the like. :)

I suspect that was the only problem with his code, but perhaps there's
something else there.


-Original Message-
From: Ben Bleything [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 8:13 PM
To: 'Matthew Loff'; 'Mark Gordon'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Dynamic SQL + result resource error


Guess I'm just a big dumbass then, aren't I =P

Oops.

I suppose that would cause it to fail then, wouldn't it?

=>  Ben

-Original Message-
From: Matthew Loff [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 5:10 PM
To: 'Ben Bleything'; 'Mark Gordon'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Dynamic SQL + result resource error


The code you're referencing is my modification of his original post. :)


-Original Message-
From: Ben Bleything [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 8:04 PM
To: 'Matthew Loff'; 'Mark Gordon'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Dynamic SQL + result resource error


Sure he is.  Right here:

$queryResult = mysql_query($sql);

what exact error is occurring?

-Original Message-
From: Matthew Loff [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 5:00 PM
To: 'Mark Gordon'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Dynamic SQL + result resource error


You aren't calling mysql_query() to execute the query.

//$find is text box input
$wordsarray = explode(" ",$find); 
$sql = "SELECT bandname FROM bands WHERE (bandname
LIKE ";
$i = 0;
while ($i < count($wordsarray)) 
{ 
$word = current($wordsarray); 
next($wordsarray);
$sql=$sql."$word)";
$i++; 
}
print "$sql";

$queryResult = mysql_query($sql);

while ($myrow=mysql_fetch_row($queryResult))
{
print "$myrow[0],";
}


-Original Message-
From: Mark Gordon [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 7:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Dynamic SQL + result resource error


Why is this code generating an error when it outputs a
valid SQL statement?  (there are no parse errors)

//$find is text box input
$wordsarray = explode(" ",$find); 
$sql = "SELECT bandname FROM bands WHERE (bandname
LIKE ";
$i = 0;
while ($i < count($wordsarray)) 
{ 
$word = current($wordsarray); 
next($wordsarray);
$sql=$sql."$word)";
$i++; 
}
print "$sql";
while ($myrow=mysql_fetch_row($sql))
{
print "$myrow[0],";
}

=
Mark
[EMAIL PROTECTED]

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-08 Thread Ben Bleything

Guess I'm just a big dumbass then, aren't I =P

Oops.

I suppose that would cause it to fail then, wouldn't it?

=>  Ben

-Original Message-
From: Matthew Loff [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 5:10 PM
To: 'Ben Bleything'; 'Mark Gordon'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Dynamic SQL + result resource error


The code you're referencing is my modification of his original post. :)


-Original Message-
From: Ben Bleything [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 8:04 PM
To: 'Matthew Loff'; 'Mark Gordon'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Dynamic SQL + result resource error


Sure he is.  Right here:

$queryResult = mysql_query($sql);

what exact error is occurring?

-Original Message-
From: Matthew Loff [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 5:00 PM
To: 'Mark Gordon'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Dynamic SQL + result resource error


You aren't calling mysql_query() to execute the query.

//$find is text box input
$wordsarray = explode(" ",$find); 
$sql = "SELECT bandname FROM bands WHERE (bandname
LIKE ";
$i = 0;
while ($i < count($wordsarray)) 
{ 
$word = current($wordsarray); 
next($wordsarray);
$sql=$sql."$word)";
$i++; 
}
print "$sql";

$queryResult = mysql_query($sql);

while ($myrow=mysql_fetch_row($queryResult))
{
print "$myrow[0],";
}


-Original Message-
From: Mark Gordon [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 7:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Dynamic SQL + result resource error


Why is this code generating an error when it outputs a
valid SQL statement?  (there are no parse errors)

//$find is text box input
$wordsarray = explode(" ",$find); 
$sql = "SELECT bandname FROM bands WHERE (bandname
LIKE ";
$i = 0;
while ($i < count($wordsarray)) 
{ 
$word = current($wordsarray); 
next($wordsarray);
$sql=$sql."$word)";
$i++; 
}
print "$sql";
while ($myrow=mysql_fetch_row($sql))
{
print "$myrow[0],";
}

=
Mark
[EMAIL PROTECTED]

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-08 Thread Matthew Loff


The code you're referencing is my modification of his original post. :)


-Original Message-
From: Ben Bleything [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 8:04 PM
To: 'Matthew Loff'; 'Mark Gordon'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Dynamic SQL + result resource error


Sure he is.  Right here:

$queryResult = mysql_query($sql);

what exact error is occurring?

-Original Message-
From: Matthew Loff [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 5:00 PM
To: 'Mark Gordon'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Dynamic SQL + result resource error


You aren't calling mysql_query() to execute the query.

//$find is text box input
$wordsarray = explode(" ",$find); 
$sql = "SELECT bandname FROM bands WHERE (bandname
LIKE ";
$i = 0;
while ($i < count($wordsarray)) 
{ 
$word = current($wordsarray); 
next($wordsarray);
$sql=$sql."$word)";
$i++; 
}
print "$sql";

$queryResult = mysql_query($sql);

while ($myrow=mysql_fetch_row($queryResult))
{
print "$myrow[0],";
}


-Original Message-
From: Mark Gordon [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 7:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Dynamic SQL + result resource error


Why is this code generating an error when it outputs a
valid SQL statement?  (there are no parse errors)

//$find is text box input
$wordsarray = explode(" ",$find); 
$sql = "SELECT bandname FROM bands WHERE (bandname
LIKE ";
$i = 0;
while ($i < count($wordsarray)) 
{ 
$word = current($wordsarray); 
next($wordsarray);
$sql=$sql."$word)";
$i++; 
}
print "$sql";
while ($myrow=mysql_fetch_row($sql))
{
print "$myrow[0],";
}

=
Mark
[EMAIL PROTECTED]

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-08 Thread Ben Bleything

Sure he is.  Right here:

$queryResult = mysql_query($sql);

what exact error is occurring?

-Original Message-
From: Matthew Loff [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 5:00 PM
To: 'Mark Gordon'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Dynamic SQL + result resource error


You aren't calling mysql_query() to execute the query.

//$find is text box input
$wordsarray = explode(" ",$find); 
$sql = "SELECT bandname FROM bands WHERE (bandname
LIKE ";
$i = 0;
while ($i < count($wordsarray)) 
{ 
$word = current($wordsarray); 
next($wordsarray);
$sql=$sql."$word)";
$i++; 
}
print "$sql";

$queryResult = mysql_query($sql);

while ($myrow=mysql_fetch_row($queryResult))
{
print "$myrow[0],";
}


-Original Message-
From: Mark Gordon [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 7:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Dynamic SQL + result resource error


Why is this code generating an error when it outputs a
valid SQL statement?  (there are no parse errors)

//$find is text box input
$wordsarray = explode(" ",$find); 
$sql = "SELECT bandname FROM bands WHERE (bandname
LIKE ";
$i = 0;
while ($i < count($wordsarray)) 
{ 
$word = current($wordsarray); 
next($wordsarray);
$sql=$sql."$word)";
$i++; 
}
print "$sql";
while ($myrow=mysql_fetch_row($sql))
{
print "$myrow[0],";
}

=
Mark
[EMAIL PROTECTED]

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-08 Thread Matthew Loff


You aren't calling mysql_query() to execute the query.

//$find is text box input
$wordsarray = explode(" ",$find); 
$sql = "SELECT bandname FROM bands WHERE (bandname
LIKE ";
$i = 0;
while ($i < count($wordsarray)) 
{ 
$word = current($wordsarray); 
next($wordsarray);
$sql=$sql."$word)";
$i++; 
}
print "$sql";

$queryResult = mysql_query($sql);

while ($myrow=mysql_fetch_row($queryResult))
{
print "$myrow[0],";
}


-Original Message-
From: Mark Gordon [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, July 08, 2001 7:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Dynamic SQL + result resource error


Why is this code generating an error when it outputs a
valid SQL statement?  (there are no parse errors)

//$find is text box input
$wordsarray = explode(" ",$find); 
$sql = "SELECT bandname FROM bands WHERE (bandname
LIKE ";
$i = 0;
while ($i < count($wordsarray)) 
{ 
$word = current($wordsarray); 
next($wordsarray);
$sql=$sql."$word)";
$i++; 
}
print "$sql";
while ($myrow=mysql_fetch_row($sql))
{
print "$myrow[0],";
}

=
Mark
[EMAIL PROTECTED]

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]