Error produced on second instance of the same code (PHP/MySQL related) 
Author Message
 Error produced on second instance of the same code (PHP/MySQL related)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This has well and truly baffled me.

I have 2 lines almost identical (but the table name) and yet I get an
error with the second instance.

Code goes like:

$sql = "
  SELECT Cat,
         Title
  FROM   {$conf['sql']['database']}.groups";
$result = mysql_query($sql, $conn);

This works fine.. but the following:

$sql2 = "
  SELECT  *
  FROM    {$conf['sql']['database']}.forums
  WHERE   Cat = '$group->Cat'";
$result2 = mysql($sql2, $conn);

Produces an error:

Incorrect database name ' SELECT * FROM forum_005.forums WHERE Cat =
'internet''

I don't understand why it works through flawlessly for the first
instance and falls over for the second.

Anyone with any ideas?

Regards,

  Ian

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0 - not licensed for commercial use: www.pgp.com

iQA/AwUBPfiUUGfqtj251CDhEQJs/ACgr7P2gH1RgHar1KkVG4WN4n/+ZbUAn3XW
bGnL5eRZVDbOU5RNJ0masS+9
=UHvK
-----END PGP SIGNATURE-----

--
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.



Mon, 30 May 2005 21:49:30 GMT  
 Error produced on second instance of the same code (PHP/MySQL related)
Hi Ian,
Quote:
> $result2 = mysql($sql2, $conn);

You should try to change "mysql" into "mysql_query" ?

Kind Regards.
Karl Heinz



Mon, 30 May 2005 21:58:13 GMT  
 Error produced on second instance of the same code (PHP/MySQL related)

Quote:

> Incorrect database name ' SELECT * FROM forum_005.forums WHERE Cat =
> 'internet''

if i read this error correctly, it is interpretting the WHOLE statement as
the database name. Note that the error does not say "error in this line",
it says, "incorrect db name 'foo'", which implies that it is giving you
what it thinks the db name is.

--
----- stephan beal
Registered Linux User #71917 http://counter.li.org
I speak for myself, not my employer. Contents may
be hot. Slippery when wet. Reading disclaimers makes
you go blind. Writing them is worse. You have been Warned.



Mon, 30 May 2005 22:34:54 GMT  
 Error produced on second instance of the same code (PHP/MySQL related)
In a fit of e{*filter*}ment on Thu, 12 Dec 2002 15:34:54 +0100, stephan beal

Quote:

> > Incorrect database name ' SELECT * FROM forum_005.forums WHERE Cat =
> > 'internet''

> if i read this error correctly, it is interpretting the WHOLE statement as
> the database name. Note that the error does not say "error in this line",
> it says, "incorrect db name 'foo'", which implies that it is giving you
> what it thinks the db name is.

The database is specified correctly.. and works exactly as it should in
the first call to the DB.

Karl has pointed out in another post..

Quote:
> $result2 = mysql($sql2, $conn);

mysql() should be mysql_query(). Hah.. it was a late night =)

Regards,

  Ian

--
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.



Mon, 30 May 2005 22:50:24 GMT  
 Error produced on second instance of the same code (PHP/MySQL related)
In a fit of e{*filter*}ment on Thu, 12 Dec 2002 14:58:13 +0100, "Karl Heinz

Quote:
> Hi Ian,
> > $result2 = mysql($sql2, $conn);
> You should try to change "mysql" into "mysql_query" ?

Hah.. thanks Karl.

It was a late night and a long day. Thanks for pointing this out =)

Regards,

  Ian

--
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.



Mon, 30 May 2005 22:51:03 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. php mysql sample code php shareware like KB knowledgebase

2. Access Denied error using mySQL through PHP

3. PHP/MySQL: strange error

4. PHP + MySQL: Got error 127 from table handler

5. error counting using php against one mysql table

6. mySQL errors after PHP upgrade

7. PHP+MySQL vs. PHP+PostgreSQL

8. php + mysql or php + postgresql?

9. TCL code producing python code

10. Linking C-Code with XF produced Code

11. PHP & tempnam producing funny file names

 

 
Powered by phpBB® Forum Software