Jump to content
Larry Ullman's Book Forums

Larry

Administrators
  • Posts

    5413
  • Joined

  • Last visited

  • Days Won

    155

Everything 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. Right. It's the same problem--a stored procedure doesn't exist--but with a different stored procedure. As the error message clearly states, the stored procedure get_shopping_cart_contents() does not exist in the database. You have to create it. In other words, do whatever you did in the other thread to get that one working.
  4. 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!
  5. 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.
  6. Thanks for the nice words, Tony, and for the interest in the books. As Jonathon pointed out, ./ and ../ are two totally separate things with different meanings.
  7. 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.
  8. I'm not sure what you mean by "shown". The code you've posted, which creates a $pn variable, would not cause that error. It'd probably help to see the full error. 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']. 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.
  9. Okay. Thanks for your input on this. If you have any specific questions or problems, I'll be happy to assist (just please create a new thread for your questions or problems).
  10. No problem, Jonathon. I appreciate the effort. What you're doing with BASE_URL is correct, you just shouldn't be using BASE_URL for include() and require() in PHP.
  11. Actually, you had beaten me, Paul, but as the administrator I have the power to travel back in time to answer questions, thereby beating people to the punch.
  12. $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.
  13. 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.
  14. Okay. To be clear, there's nothing in the error message to suggest that the MySQLi functions are the problem. It's a simple database connection error. I wouldn't be surprised to hear you failed to reload the MySQL privileges after adding a user or making other changes.
  15. Isn't this the same problem you posted in another thread, with just a different stored procedure not defined yet?
  16. Just to confirm, you're running a Mac and connecting to MS SQL server on another machine, correct? It's a matter of configuring and building PHP. There are tutorials online for this, but it's not for the faint of heart. 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). 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. 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.
  17. 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.
  18. So which bit of code is giving you the error message? Also, in your login page, does $pid exist?
  19. I also don't know if the session ID is validated to any degree. For example, actual session IDs are exactly 32 characters long and contain hexadecimal characters.
  20. First of all, thanks for using the forums instead of posting this question in the comments section of the blog. Very much appreciated (too hard answering complex questions there). Let me review my code and what Yii's doing these days and I'll get back to you.
  21. Thanks, Jay, for the nice words on the book. I'm glad that you like it and it's nice of you to say so. Feel free to post your questions here as you have them!
  22. Well, Apache does have virtual directories, I just didn't realize that PHP reported on that setting. You'll need to change a setting in your httpd.conf file. If you search online, you'll find more information.
  23. That's helpful to see. As you can tell from your own code, there is no $_SESSION['product_name'] being created. You're creating $_SESSION['cart'][$pid]['product_name']. This is just the same as you have with the price.
  24. What does "not working" mean? Do you see errors? If so, what are they? If phpinfo() says that MySQLI support is enabled, then it's enabled.
  25. The MySQL manual shows how to limit an INDEX to a certain length: http://dev.mysql.com/doc/refman/5.0/en/column-indexes.html Why do you think you want to index the entire tinyblob column? That will be inefficient. In fact, why do you think you want to index the tinyblob column at all?
×
×
  • Create New...