Jump to content

MySQL experts help me plz


Recommended Posts

OK, so I'm testing out how to use stored procedures in MySQL on my local machine....

 

I create a very simple one that retrieves all the data from a table call `book`.

 

Then run the command "CALL get_all_books()" and all it does is give me this error...

 

 

Error

 

SQL query:

 

SELECT DATABASE( ) AS 'db';

 

MySQL said: Documentation

#2014 - Commands out of sync; you can't run this command now

 

Trying to figure this one out is giving me a headache. Any help would be appreciated.

 

Thanks.

Link to comment
Share on other sites

Did you connect to your database by using mysql_connect()

$dbserver = "localhost";

$dbuser = "root";

$dbpass = "";

$dbname = "test";

 

mysql_connect("$dbserver", "$dbuser", "$dbpass");

 

And also remember to use mysql_select_db() and other commands.

This method is use with PHP.

Link to comment
Share on other sites

Thanks for the reply JcX...

 

I forgot to say that I was using phpmyadmin the whole time, so I don't think that's the problem.

 

I've looked up tutorials online about stored procedures and follow them step by step. But I still get this error.

 

Don't know if it's some weird setting I need to change.

 

I'm using the latest version of wamp with its default settings.

Link to comment
Share on other sites

Where are you running the query from? Did you select a database and then the SQL tab from there, or did you click the SQL icon on the top of the left panel?

 

 

I pretty much tried everything :)

 

It seems I can call the stored procedure from a php web page though. So I guess that's just what I'll have to do to test it out.

 

Thanks.

Link to comment
Share on other sites

My guess is that you are running the procedure from a situation where a database has not yet been selected. Make sure you select a database, then enter some random table or something and go to the SQL tab and try there.

Link to comment
Share on other sites

I've tried running the procedure after having selected the database, without selecting it, and from just about every window that I possibly can within phpMyAdmin.

 

Just wondering... have you ever tried running a procedure in phpMyAdmin? If it worked for you, how did you do it?

 

 

I just tried running the procedure from the mysql console and it works. It's definitely something about my installation of phpMyAdmin.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...