Jump to content
Larry Ullman's Book Forums

Larry

Administrators
  • Posts

    5413
  • Joined

  • Last visited

  • Days Won

    155

Posts posted by Larry

  1. No, I'm suggesting you create constants representing key files that are included, just like I do with the MySQL connection script. By defining the entire path to the file, including the file's name itself, as a constant, you'd only ever have to change one line in one configuration file should you need to make a big change later.

  2. The specifics of what Nick is doing still aren't clear, as far as I can tell, but HartleySan, say you have a product in an ecommerce database and you have multiple images associated with that product. All of the product particulars--description, id, price, etc.--would go in the one table and records reflecting each associated image (and each product could have from 1 to ??? images) would go in a second.

  3. Thank you very much, Charles, for the nice words and for the interest in my books. It is appreciated. As for your question, and off topic is fine, clearly the best language is...oh, wait.

     

    Actually, I don't have any personal experience with Python. I've heard very good things about it, but couldn't speak to it's strengths or weaknesses, let alone compare it to Ruby. Sorry I can't be of more help!

  4. Thanks for the nice words on the book, Lou, and for your question. I agree that everyone should be using MySQLi, if they can. However, a surprising number of Web hosts still don't support MySQLi. And the mysql functions are more forgiving in terms of forgetting to specify the database connection. So I think for beginners, the mysql functions are the softest introduction still. In the next edition, I'll probably make the switch, but this is something I consider and, especially because this book is for beginners, I'm erring on the side of caution.

  5. Well, you can't "amend" the error, exactly. What you can do is use the up key to find the problematic line, edit it, and hit enter. Note that you have to keep the whole syntax of the query intact, meaning that if the query goes over multiple lines, you'd need to use the up key multiple times and do it in the right order.

     

    If this still doesn't make any sense, it'd help to know what version of MySQL you're using, on what operating system, and what an example is of something you're having problems with.

  6. It works fine in the basket.php page and the $pn is shown.

     

    I'm not sure what you mean by "shown".

     

    In the logincustomer.php page. I get the 'Undefined variable: pn

     

    The code you've posted, which creates a $pn variable, would not cause that error. It'd probably help to see the full error.

     

     

    No, the $pid is not in the loginpage:

     

    Okay. If $pid is not in the loginpage (is that the same as the logincustomer.php page?), then you can refer to $_SESSION['cart'][$pid]['product_name'].

     

    $pid is as the example in your book where you have $aid, but instead of artist id I have product id. Should this be in the loginpage and where?

     

     

    I think you're confused here. In the book, $aid is an artist's ID and $pid is a product ID. $pid represents a specific item being purchased. I don't know why a $pid would be involved with a login page, but it's really not clear what you're doing here.

     

     

  7. $query5 will always create one row, so the result should always be 1 and mysqli_affected_rows() is the function you'll need to call. If you want to count how many times that query is executed (i.e., how many total rows were affected by the loop), create a new variable before the loop, with an initial value of 0. Then, within the loop, do

    $affected += mysqli_affected_rows();

     

    After the loop is done, $affected with reflect the total number.

  8. A bunch of responses...

     

    Thanks to you guys for the thread and for helping each other out.

     

    Thanks to Tony for the nice words on the book. And this is a fine place for such a question.

     

    Jonathon, to be clear, you wouldn't want to use a BASE_URL constant to include files as that is a URL reference and you don't (generally) want to include files over HTTP. I use BASE_URI for an absolute path to files on the server.

     

    HartleySan, yes, this seems to be a point of confusion, especially in the e-commerce book which requires absolute HTML paths because of mod_rewrite. And when people put one example in folder A and another example in folder B, both end up being in subfolders of the Web root directory. I'll try to cover this topic in more detail in the future.

     

    I don't think there are differences between XAMPP and live hosting, or, at least, the actual differences are in the OSes involved and the directory structures and such. But XAMPP doesn't do anything that differently in this regard, as far as I know.

  9. Okay, thank you. I installed XAMPP hoping that it might have more support features than MAMP. However, it still doesn't seem to want to connect to a ms sql server.

     

    Just to confirm, you're running a Mac and connecting to MS SQL server on another machine, correct?

     

    1. Paul, you mentioned that I might have to "'re-make' PHP". Can you explain more on that?

     

    It's a matter of configuring and building PHP. There are tutorials online for this, but it's not for the faint of heart.

     

    2. The php.ini in XAMPP file does not contain a line with "mssql.so". This is why I think that something needs to be installed somewhere.

     

    If PHP is running on a Mac, then it doesn't surprise me that there's no mention of mssql.so. More importantly, there's probably no mssql.so on your computer (you can search for it, to be certain).

     

    Also, someone suggested I invest $35 in an ODBC driver such as the one here:

    https://www.actualtech.com/buynow.php

     

    saying that this will provide the connectivity.

     

    Don't do that. You can actually just use PHP's ODBC driver. The ODBC driver is just a generic interface that works with many database applications. You can also use PDO ODBC, too.

     

    FYI, here is the code I am using to try and connect with the server:

     

    I appreciate you including as much information as possible, but the code isn't really relevant until you know you've got an extension that will work with MS SQL.

  10. You don't need to index an entire BLOB or TEXT column. In fact, by restricting the index, you'll get much better performance. What you'd want to do is index whatever X number of characters will reasonably index unique results. With a column like this, I'd think you could get away with indexing the first 10 or 20 characters. You can always change the index later, once you have a sense of the data, too.

  11. Yes I am using a mac and have tried setting to '/Applications/MAMP/htdocs/'. For some reason it's still not working.

     

    What does "not working" mean? Do you see errors? If so, what are they?

     

    As for mysqli I'm using PHP5 with mysql v 5.1x so I should be fine with the versions. I think there is probably some setting that I'm missing in the config file for apache. Would you happen to know what this could be?

     

    If phpinfo() says that MySQLI support is enabled, then it's enabled.

     

×
×
  • Create New...