Forum Moderators: coopster

Message Too Old, No Replies

Parse error with mysql_select_db

         

pixel_juice

11:42 pm on Jul 16, 2003 (gmt 0)

10+ Year Member



I'm taking my first steps into the world of mysql and I've hit on an early problem.

When my (extremely simple) script tries to select the database I created, I get a parse error. The line i'm using is just:

mysql_select_db("testdb",$db);

Anyone have any suggestions as to what (probably obvious) error i'm making? It's driving me mad, because I want to play with my database :)

jatar_k

11:54 pm on Jul 16, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



assuming the name of the db is exact (case et al).

Lets see the mysql_connect as well. Also the resource link_identifier is an optional param, the function will assume the last opened link.

Asandir

4:16 am on Jul 17, 2003 (gmt 0)

10+ Year Member



If it's a simple script, I'm assuming you won't be connecting to more than once resource.

Which means you won't need the second parameter.

try
mysql_select_db("dbname");

"mysql_select_db() sets the current active database on the server that's associated with the specified link identifier. If no link identifier is specified, the last opened link is assumed."

edit: just as jatar_k said, I didnt notice his post.

pixel_juice

9:59 am on Jul 17, 2003 (gmt 0)

10+ Year Member



Thanks for the suggestions. I have a feeling I may be bombarding you guys with newbie database questions. Apologies in advance ;)

The parse error was a missing semi-colon in the previous line where I start the connection to the sql server (duh!) which in the cold light of day I noticed and remedied.

However, now I'm stuck with a different error:

No Database Selected

The line I'm using is still mysql_select_db("testdb",$db);

Surely I am selecting the testdb database? I do have more than one database set up, so I don't know if this would be affecting it.

Before I started working on mysql, I was pretty intimidated by the whole database idea. It seems I was right to be ;)

Thanks for any help or advice.

pixel_juice

10:09 am on Jul 17, 2003 (gmt 0)

10+ Year Member



Hey, scrub that last post, the problem was the username I was using to make the connection.

/off to play with databases :)

jatar_k

2:29 pm on Jul 17, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



glad you figured it out pixel_juice.

A good way to post about error messages is to post the exact error and then the offending line that is referenced by the error.

pixel_juice

2:37 pm on Jul 17, 2003 (gmt 0)

10+ Year Member



Thanks jatar_k :)

>>A good way to post about error messages is to post the exact error and then the offending line that is referenced by the error.

I did try I promise ;)

The first problem above mainly resulted from the error message referring to line 8 of my script, when the missing semi-colon was actually on line 6 so I didn't check out the preceeding code too carefully.

If you have a minute i'd really appreciate it if you could help me with my next problem. [webmasterworld.com]

I think me learning mysql is gonna be like configuring a personal firewall - very noisy in the beginning, and then goes quiet and just keeps ticking along in the background ;)