AndrewT Posted September 13, 2011 Share Posted September 13, 2011 I am using this book currently as a guide of sorts to create an e-commerce store that doesn't sell coffee. So far, I have only modified the SQL here and there. To be specific, I am creating a store that sells handmade soap (long story). I have modified the SQL so that the tables, instead of having "coffee" in the name, have "soap" in the name. Also, instead of passing "goodies" or "coffee" to the "select_categories" procedure in shop.php, it will pass either "goodies" or "soaps". I have changed the corresponding stored procedures accordingly when I inserted them. Here is my problem. When I test the script shop.php, I get the error "mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given". I have troubleshooted for a while now and figured I would post on the forums in the hope that someone could help me out. I haven't been able to test the Stored Procedures as I am using phpMyAdmin and get errors when I try to run stored procedures. I created them fine, but I can't test them, at least not in phpMyAdmin. Is there a way to make sure they work outside of phpMyAdmin? My guess is that the stored procedure is getting screwed up somehow, and so it is returning "false" instead of a number of rows returned. If anyone has any questions to better understand my code or anything, just let me know and I will be happy to do anything to get this problem resolved. Thanks! Link to comment Share on other sites More sharing options...
Jonathon Posted September 13, 2011 Share Posted September 13, 2011 You should be able to test them, I just ran this code in my PHPMyAdmin call select_sale_items(1); Have you definitely got the full permissions enables to be able to execute stored procedures? Link to comment Share on other sites More sharing options...
AndrewT Posted September 13, 2011 Author Share Posted September 13, 2011 Yeah I have full permission on the database server. Here is the error I get when I try to run a stored procedure: #1312 - PROCEDURE andrew_pss.select_categories can't return a result set in the given context It auto appends andrew_pss (the database name) to the procedure. I have tried it from just about everywhere inside phpMyAdmin and I still get that error. I get that error on every procedure as well. Link to comment Share on other sites More sharing options...
Larry Posted September 14, 2011 Share Posted September 14, 2011 Using the command-line mysql client is a better option than phpMyAdmin, but maybe one you don't have. You can just create a PHP script that executes the stored procedure and reports upon the results, for testing purposes. Link to comment Share on other sites More sharing options...
AndrewT Posted September 14, 2011 Author Share Posted September 14, 2011 I have a local installation of Xampp for testing some PHP scripts, and I believe that I can connect to my remote server using the MySQL command line installed with Xampp. I will Google it and try. I also might install a standalone MySQL administration client and connect remotely. I am hoping that the error with my PHP script is something simple and I wont have to go re-write all the Stored Procedures haha. Thanks for the help! I will update with what the problem is when I figure it out. Link to comment Share on other sites More sharing options...
Larry Posted September 14, 2011 Share Posted September 14, 2011 I would hope that you could not connect remotely to MySQL, as that'd be less secure. But let us know how you make out and if you need any other help. Link to comment Share on other sites More sharing options...
AndrewT Posted September 15, 2011 Author Share Posted September 15, 2011 To connect remotely to my server I have to log into the cPanel and add my IP to the hosts list. And since my IP is changing all the time (student) I delete the IP from the list as soon as I am done. I figured out the problem though. The user that I am using in the mysql.inc.php file to log into the database to display categories and products didn't have permission to execute Stored Procedures. All I had to do was give that user Execute permission and the script works flawlessly now. So it turns out Jonathan was right, I just misinterpreted his post. I thought he meant do I have the permission from the administrator perspective, not do I have the permission set on the user logging in. My bad! Link to comment Share on other sites More sharing options...
Jonathon Posted September 15, 2011 Share Posted September 15, 2011 Perhaps I should explain clearer - apologies. Glad it's working for you though. Link to comment Share on other sites More sharing options...
Recommended Posts