Jump to content
Larry Ullman's Book Forums

xcrider2

Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by xcrider2

  1. xcrider2, I would set the base URI to C:\xampp\htdocs\, but you get the idea. If you have the base URI set up like that, you can better simulate the structure Larry recommends in the book, which is putting the MySQLI connect file outside of the Web root directory, etc. Actually, you might be able to set the base URI even to just C:\xampp\, but I am not sure if localhost can access files outside of the htdocs folder by default. Well, regardless, I think you have the right idea. It is tricky, and I ended up having to play around with it a bit myself until I figured it out in Windows using XAMPP as well.

     

    Thanks very much HartleySan,

    Yes, this is tricky, but your suggestion works perfectly.

    I did notice that I had to put an extra \ in there because just one winds up escaping the single quote on the end.

    So, I settled on 'C:\xampp\htdocs\\'

     

    Hopefully, this thread will help others who come straight over from Larry's PHP6 And MySQL5 Quick Pro Guide with their handy Xampp installation. To these folks, I also recommend that you use the mysql Client from the command line interface, rather than phpMyAdmin, to set up the stored procedures. This was another tricky part for me, since phpMyAdmin doesn't seem to work consistently with stored procedures.

  2. Did you specifically setup a site within XAMP that points to that ex2 folder? So if you associated something like http://www.ex2.lcl then it opens to the ex2 folder? OR are you just using the default settings and haven't customized it yet?

     

     

     

    I was looking at this today actually in a tutorial I found in another book.

     

    EDIT:

     

    Document Root is considered to be the BASE_URI. In other words it is the starting folder that is accessible to the web browsers and any sub folder underneath it. the folder the current file is located in.

    There are several definitions that all mean the same thing, web root, document root, base_uri are the same.

     

    URI, some consider to be path to webroot but if you look at the context URI is usually used in it is just the file path to a location a folder or file. It does NOT have to be to a web accessible folder or file though. I noticed also that URI is interchangeably used when referencing web URL paths as well, just to add to the confusion I think. You have to pay attention to context of what the person using it is trying to explain, they may have the definition wrong OR we do... LOL

     

     

     

     

     

    EDIT:

     

    It is whatever phpinfo told you the document root is. EXACTLY typed as it says it is.

     

    The BASE_URI is the parent folder, the starting folder that is web accessible. When you type the address into your web browser that first folder that gets accessed is your BASE_URI.

     

    http://www.ex2.lcl if you had that setup in your virtual hosts file then whatever folder that is pointing to is the BASE_URI for that site.

     

    IF in your testing environment you are using the default settings with no virtual hosts setup and you have to type:

     

     

     

    Then technically whatever folder localhost itself points to is the BASE_URI but in context of the site you are working in then \ex2 is your base_uri or web root.

    BUT you can't just type \ex2 and that is it.. you have to type the actual file path to that folder so if it is in C:\htdocs\ex2 then you have to put that whole thing into the BASE_URI definition.

     

     

     

     

    The REQUEST_URI is different from URI and document root and files.

     

    Without going to look up the exact definition for you I will just explain my observation of it.

    REQUEST_URI is everything "AFTER" the www.yoursite.com in the URL.

     

    This could be information you are passing such as variables, session information, folder or page.

    It comes in handy when you need to know everything that is passed to your files without knowing exactly what is there and you already know the domain name.

     

    --------------

     

    I do not use XAMP or any specific premade installer that puts apache, mysql, php etc... on your windows computer and sets things up for you.

    I used to use Vertrigo which is a different flavor of these type of software, the problem I had was when I needed a specific install of apache or php or mysql you are kind of stuck.

    Now I manually go to each applications website and download then install the version closest to what I need and then I manually configure the config files how I need. I do not see any difference,

    between doing it manually and using one of the premade softwares like XAMP except manually it gets setup how I want it.

     

    I also created a little utility that I use to start and stop Apache and MySQL, restart them and tell me if they are currently running or not.

     

    In Apache's httpd.conf file there is a section at the bottom that either links to a seperate file OR is contained within httpd.conf that allows you to setup virtual hosts.

    This is what you use to setup something like http://www.ex1.lcl and point that to say /ex1 folder off of your web root but the brilliance of these virtual hosts is they do not have to be inside the predefined web root XAMP or whatever sets up for you. I have mine all setup on a seperate hard drive from my operating system drive, this folder could also be on a flash usb stick if you wanted. Of course you have to have the flash stick connected to a working USB connection.

     

    The reason I said all that is when you setup a new virtual host that points to a specific folder, then THAT folder becomes the new web root for that site. I have 30 or 40 seperate web roots contained within my virtual hosts file for my installation of apache. Just typing the specific local site into my web browser takes me to that specific site.

     

    The new version of Apache the virtual hosts are located in a seperate file linked to from the httpd.conf file, they all used to be inside that one file. I think the particular premade installation software I used the creators consolidated into one file, but in the standalone apache you can download off apache's site all these things are in seperate files located in etc subfolder. Took me awhile to figure it out but I got it all working.

     

    Ok, Thanks very much for the thorough explanation Terry...

    So, for an Xampp instalation with default settings, I believe that my BASE_URI for this excercise is: C:\xampp\htdocs\ex2\

    Is there a practical way to test and confirm that the BASE_URI is correct?

    I suppose that if the application has access to the database, then the BASE_URI must be right, since the path to MYSQL is defined as: BASE_URI . 'mysqli.inc.php'

  3. I primarily used the command line mysql client to test the procedures, although I think I created and edited them using phpMyAdmin. Some people experience problems with stored procedures in phpMyAdmin and others don't. It's not clear what the main difference is. Here's what I had written in a thread in the old forum (http://www.larryullm...ad.php?24,50607):

     

    I don't know what version of phpMyAdmin I used previously as I just upgraded. I'm now using phpMyAdmin 3.2.5 with PHP 5.3.2 and MySQL 5.1.44. It's using the mysql PHP extension. This time I could call the stored procedures using either the SQL tab or the SQL popup, so long as I named the database--CALL ecommerce2.select_sale_items(1)--and so long as I DID NOT select the database in phpMyAdmin first. In other words, I had to be on the phpMyAdmin home page to start. Clearly, phpMyAdmin is inconsistent about how it deals with stored procedures.

     

    Thanks Larry,

    This is a good excuse to go back and learn to use the command line mysql client. phpMyAdmin is great for beginners, and I am going to miss using it as I go through this book, but I am sure there are other advantages to learning how to use mysql client.

     

    I found that mysql client is covered in chapter 4 of your PHP6 And MySQL5 Quick Pro Guide. I am good to go.

  4. How is phpMyAdmin running, is it setup to use mysql OR mysqli?

     

    Most phpMyAdmin's I have seen use mysql not mysqli. IF you are using a testing environment for the site then go into phpmyadmin's config file and tell it to use mysqli. IF you are on a hosted site where you have root access you can change the config file there too, though sadly if you are on shared hosting you are stuck with whatever they have it set to use.

     

    That is only thing I can think of is it is mysql not mysqli. Sounds like a configuration issue or database issue of some kind if phpMyAdmin is running with mysqli.

     

    Thanks Terry,

    I am just using my local host and it is running mysqli.

    The procedures that I entered into the SQL command box are stored in the database, it is just that phpmyadmin doesn't recognize them at all. They don't show up on the main admin area with all the tables. You can't test them. You can't even tell that they are there unless you try to enter one again and it gives you an error that the procedure already exists. Or, if you run an information schema query it shows them, but you cannot edit them at all. I did a google search and found that it is a common, inconsistent problem. No clear solutions except using something other than phpmyadmin.... This is a shame, phpmyadmin is easy to learn and use.

  5. I have the same lack of understanding of the URI and this thread is very helpful. Thanks.

    I think I now understand how to set it up on a hosted server, where you have a file structure like: /Users/Username/Sites/ex2/. This is how Larry's example is laid out in the downloadable code.

    How about for those working on a local host with Xampp for example? I am just unsure how far back we have to go to define the base URI of the site.

    I did not find any specific BASE_URI answer in phpinfo().

    The "Document Root" is C:/xampp/htdocs

    So would the BASE_URI be something like C:/xampp/htdocs/ex2/ ?

    Or would it be /xampp/htdocs/ex2/ ?

     

    The REQUEST_URI when I ran php_info was /ex2/php_info.php

    So could the BASE_URI for those of us using a local host just be /ex2/ ?

     

    Or would you start with /Users/ when working on your local host as well?

     

    Thanks again for the helpful thread.....

  6. Hello all,

     

    I am starting the stored procedures in chptr 8 and having difficulty testing them.

    I have always used phpMyAdmin, but it seems that this might not be the best thing for working with stored procedures.

    I can verify that the procedure exists with SELECT * FROM information_schema.routines;

    but I cannot edit them through the phpMyAdmin interface.

     

    Further, when I call a stored procedure to test it, I just get booted out of the ecommerce2 database and wind up on the phpMyAdmin homepage.

     

    Any suggestions would be greatly appreciated.

     

    phpMyAdmin Version information: 3.2.4

    MySQL client version: 5.1.41

    Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1

×
×
  • Create New...