Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in select statement

Status
Not open for further replies.

richclever

IS-IT--Management
Oct 5, 2000
127
FR
I can run my script on one server but not on another.

I get the following error when I try to access the page:

Couldn't execute statement: 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 ''0',30' at line 1; stoppedContent-type: text/html

The part of the file in question is:

$statement = 'SELECT * FROM staff WHERE username != "admin" LIMIT ?,30';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute($showp) or die print "Couldn't execute statement: $DBI::errstr; stopped";
while(my $ref = $sth->fetchrow_hashref()) {


As I say, it works on a different server but not on the other one. The version of perl we are using is:

perl 5.8.0-88

and the version of mysql is:

4.0.20

DBI and DBD are both installed and working.

Thanks

Rich
 
It looks like it's a problem with the SQL statement itself. I don't use MySQL personnaly, but you may try changing the != to <> and see if it runs. I'd also try running the statement directly against the database in question.

- Rieekan
 
It seems like $showp is being wrongly passed, but not sure. Because the error says you have single quotes around 0, which is being passed by $showp.
Also as a precaution, try to place the select statement in double quotes, and admin in select statement with single quotes.
But I am not sure why it is working in one server and not working in other server.
 
The script in question is perldesk version 1.5.5 if that is any help.
 
Rich,

Check the version numbers of all modules used, and make sure they're equal or higher than the machine that works. If that's OK, you could try bringing the modules back in line with the working machine, to determine which module is faulty.

If everthing else has been exhausted, then you're looking for a subtle difference

--Paul

cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top