Good advice. I'll try it out. But the problem occurs before the query. I tried 
printing $var 
prior to the query and it does not print. Then, I get the 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 'WHERE begins = '0'' at line 4"



--- In [email protected], <[EMAIL PROTECTED]> wrote:
>
> ----- Original Message ----- 
> From: "whoisquilty"
> 
> I've got a form with a pulldown on my main page. The user chooses from the 
> pulldown
> and that is passed to the secondary page. That variable is supposed to 
> search the database
> and display the results.
> 
> However, the secondary page is not getting the variable. It shows in the 
> URL, but it shows
> as 0 in the DB query.
> 
> Here's the form code:
> 
> <select name="var" size="1">
> <option value="A">A</option>
> <option value="B">B</option>
> <option value="C">C</option>
> <option value="E">E</option>
> <snip>
> Here's the code from the secondary page:
> 
> $var = floor($_GET['var']);
> 
> mysql_connect('x', 'x', 'x');
> 
> mysql_select_db('x');
> 
> $query = "SELECT *
> FROM shows
> ORDER BY sorttitle
> WHERE begins = '$var'";
> 
> What's going on?!
> -----------------------------
> PHP will NOT substitute values for variables that are enclosed in single 
> qoutes - use the following syntax -
> 
> $query = "SELECT *
> FROM shows
> ORDER BY sorttitle
> WHERE begins = \'" . $var . "\'";
> 
> OR
> 
> $query = 'SELECT *
> FROM shows
> ORDER BY sorttitle
> WHERE begins = "' . $var . '"';
> 
> can also try -
> 
> $query = "SELECT *
> FROM shows
> ORDER BY sorttitle
> WHERE begins = '{$var}'";
>



Reply via email to