Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Something dumb


Message #1 by Jefferis Peterson <jefferis@p...> on Fri, 20 Sep 2002 16:36:33 -0400
Do a screen dump of your SQL Statement (echo $SQL) and stop the execution of
your page at that point. Remember you are generating a string, you want to
generate the right string. Checking the manual (always a good idea) it
states that strings can be enclosed in single or double quotes. They
recommend that you enclose them in single quotes:
http://www.php.net/manual/en/printwn/language.types.string.php

This would mean that you must escape the quotes.

regards
David Cameron
nOw.b2b
dcameron@i...

> -----Original Message-----
> From: Jefferis Peterson [mailto:jefferis@p...]
> Sent: Saturday, 21 September 2002 6:37 AM
> To: sql language
> Subject: [sql_language] Something dumb
> 
> 
> Trying to set a default query from form post with the 
> variable text input
> 'keysearch'  from form. This query however stalls on output 
> unless I put in
> a non variable in for keysearch...
> What am I doing wrong?
> 
> > <?php require_once('Connections/jodenonline.php'); ?>
> > <?php
> > $keysearch_searchreturns = "%yellow%";
> > if (isset(keysearch)) {
> > $keysearch_searchreturns = (get_magic_quotes_gpc()) ? keysearch :
> > addslashes(keysearch);
> > }
> > mysql_select_db($database_jodenonline, $jodenonline);
> > $query_searchreturns = sprintf("SELECT * FROM `Catalog` WHERE
> > `Catalog`.keywords LIKE '$keysearch_searchreturns'  AND 
> `Catalog`.img_status 
> > "1"", $keysearch_searchreturns);
> > $searchreturns = mysql_query($query_searchreturns, $jodenonline) or
> > die(mysql_error());
> > $row_searchreturns = mysql_fetch_assoc($searchreturns);
> > $totalRows_searchreturns = mysql_num_rows($searchreturns);
> > 
> > ?>
> > <html>
> > <head>
> > <title>Search Display</title>
> > <meta http-equiv="Content-Type" content="text/html; 
> charset=iso-8859-1">
> > </head>
> > <body bgcolor="black" text="#ffffcc" link="#ffffcc">
> > 
> > <div align="center"> </div>
> > <p>First Next <?php echo $HTTP_POST_VARS['keysearch']; ?> <?php echo
> > urlencode($HTTP_POST_VARS['period']); ?> <?php echo 
> $HTTP_POST_VARS['class'];
> > ?> <?php echo $HTTP_POST_VARS['type']; ?> </p>
> > <p>&nbsp; </p>
> > </body>
> > </html>
> > <?php
> > mysql_free_result($searchreturns);
> > ?>
> ~~~~~~~~~~~~
> Jefferis Peterson, Pres.
> Web Design and Marketing
> http://www.PetersonSales.net
> Tel .  xxx-xxx-xxxx
> ICQ 19112253
> 
> http://www.Slippery-Rock.com - 7,000 hits per year
> 
> 
> 


  Return to Index