Jump to content
Larry Ullman's Book Forums

Sql Stored Procedures And Phpmyadmin


Recommended Posts

Hi Larry,

 

Thanks very much for writing this book. I have come a bit unstuck and really hope you can help me!!

1) In the book you say that all the SQL commands can be downloaded. I can't seem to find them anywhere? Are they within the zip files?

 

2) My biggie question: I have been working perfectly up until the 'stored procedures' section (an area I see a few others have struggled with too). I use the justhost C-Panel which has PhpMyadmin for all the mysql database work. I cannot seem to create or work with the stored procedures on here. When I googled it, it said that essentially PhpMyadmin doesn't support this functionality. Can you make any suggestions as to how I could get this to work? One thought was to create a php function instead but I'm not sure entirely how that would work! Is there an alternative method?

 

I would say I am still fairly new to Php and web design but I do have a reasonable understanding and feel that essentially I could successfully complete this book. Stored Procedures is something I have never encountered before so if you can help me I would be extremely grateful. Apologies if I'm asking thats already been asked but I thought best to put my question in my own words.

 

I very much look forward to your reply.

 

Happy new year!!

Lew

Link to comment
Share on other sites

Thanks Jonathon. It's great to know that this is possible. Could you elaborate on how I would do this please? Do I need to create a .sql file myself in my text editor with these procedures in order to be able to call them? What I mean is, if I use the .sql file and execute the query using a php command should this work if I include the sql page? Having had a peak at the zip file, it would seem this is the case. I saw an 'include (mysql)' command on the shop page. What specifically does this command refer to? Thanks for your help and for helping me learn this stuff!! Lew

Link to comment
Share on other sites

There is a "sql.sql" file in Larry's zip folder. Inside it you will see a series of SQL commands like:

CREATE TABLE `carts` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `quantity` tinyint(3) unsigned NOT NULL,
 `user_session_id` char(32) NOT NULL,
 `product_type` enum('coffee','other') NOT NULL,
 `product_id` mediumint(8) unsigned NOT NULL,
 `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
 `date_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
 PRIMARY KEY (`id`),
 KEY `product_type` (`product_type`,`product_id`),
 KEY `user_session_id` (`user_session_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

 

You can copy these commands and run them inside PHPMyAdmin. You will see in the centre of the page a SQL tab, where you paste these queries and then execute. You are not including the sql file anywhere or executing it using PHP.

 

on line 23 there is a

// Require the database connection:
require (MYSQL);

 

This is calling the constant established in your mysqli/config file.

  • Upvote 1
Link to comment
Share on other sites

You can just copy the commands from the text file and paste them into the phpMyAdmin SQL tab or popup window.

 

Not to be too harsh, though, if you don't know what include (MYSQL) means, this book is probably going to be too advanced for you. And, you should also already know that there's a big difference between MYSQL in the code and mysql in your post.

Link to comment
Share on other sites

Thanks Larry, I love a challenge and will work this out. If you think this is going to be too advanced for me than perhaps you could suggest some resources in which I can learn the skills required? I am intrigued by your last sentence and would love to know what the difference is that you are referring to? It's all a learning curve, I need to learn all this stuff so if you are prepared to offer some advice, then that would be great. How did you learn it? I feel I can follow all the PHP stuff, but I will admit that I haven't taken many tutorials in mysql (which I will address). I look forward to working on. Thanks for your help, Lew

Link to comment
Share on other sites

Well, you know yourself better than I do, and know what you're capable of. But this book was specifically written for those with sound knowledge of PHP and MySQL. You can learn the skills you need from my "PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)" book, or from any number of online resources.

 

As for the difference between MYSQL and mysql, PHP is case-sensitive when it comes to variables and constants. That's a basic fact that you'd need to know to do anything in PHP. You should also already be able to recognize that MYSQL is a user-defined constant in PHP, whereas $mysql would be a variable.

 

One of the key reasons one needs comfort with PHP and MySQL before taking on a task like e-commerce or the specific book examples is the ability to debug problems when they occur. That knowledge only comes from experience.

 

When I started learning PHP, in 1999, there were only two books on the subject, I believe, so I learned from the PHP manual and from doing. The lack of good books on PHP is why I started writing books.

Link to comment
Share on other sites

 Share

×
×
  • Create New...