James - Sorry, I knew I was missing something in my initial post.

The column that $prodvar is set from is an INT column.

And the error that I get is:

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 'ORDER BY yearopen' at line 4

Looking at my code:

"SELECT *
        FROM productions
        WHERE showno = $prodvar
        ORDER BY yearopen";

...the Where statement is the problem. If I remove the Where statement, it 
works fine. I 
tried the previous suggestion of putting $prodvar as '$prodvar' or ".$prodvar." 
Neither 
worked. '$prodvar' returned no results. And ".$prodvar." gave me the same error 
as above.

Unfortunately, I can't find listed anywhere on my the phpMyAdmin site that I'm 
using 
anything that indicates what version of MySQL or PHP that is installed. The 
version of 
phpMyAdmin that is being used is 2.7.0.-pl2

That's the information I've got. If I'm missing anything, let me know.

Jer

--- In [email protected], James Keeline <[EMAIL PROTECTED]> wrote:
>
> --- whoisquilty <[EMAIL PROTECTED]> wrote:
> 
> > I switched web hosts and I'm trying to get everything up and going. But, the
> > queries that had worked before, don't work anymore.
> > 
> > If there is a variable passed, it doesn't work:
> > 
> > "SELECT *
> >     FROM productions
> >     WHERE showno = $prodvar
> >     ORDER BY yearopen";
> > 
> > If I put the variable that $prodvar is set to in the query instead of
> > $prodvar, it works fine. So, 
> > why is this wrong on a different server?
> > 
> > Thanks for the help.
> > 
> > Jer
> 
> Is showno an integer?  Even if it is you may want to surround the variable in
> single quotes:
> 
> WHERE showno = '$prodvar'
> 
> This way, if $prodvar is empty or not defined then it will equate to 0 on an
> integer field.  The SQL will still be valid but may not return any rows.  As
> you have it, if the variable is not set, the SQL will break and return an
> error.
> 
> 
> You also don't say how $prodvar is populated or validated.  If you are using 
> an
> assumption that REGISTER_GLOBALS is on, a modern server with it off could
> create surprising results like this.
> 
> 
> In brief, you don't supply us with enough information.  I get that it doesn't
> work but you don't say what errors are generated, whether you can successfully
> connect to the database on this new server, etc.
> 
> James Keeline
>


Reply via email to