Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. I agree with the prior advice, but I have my own spin. Read a test driven development book and if you buy into that, pick a clearly defined module to try that out and see if it works for you. It's worth pointing out that there is a category of automated testing that is different from unit tests. As mentioned, Selenium and Watir are two open source tools that allow you to automate tests for a web application. You might find that these are of greater benefit to you in the near term in your goals of having tests for your application that you can run against a working system. Having a source code mgmt system is huge, and as a long time user of vc, and having done a lot of work with subversion, I'd recommend going directly to git. There are numerous tutorials you can find. You'll get value out of it, purely in having a way to track versions of your own code, and the day you screw up a source code file accidently, you'll be overjoyed that you took the time to set up something that lets you go check out a previous version, or compare the changes that you made, when a bug suddenly pops up in your latest release.
  2. I'm not quite sure I follow what you are asking for. If I have a dependent relationship (in data modelling parlance that would be called making the relationship "identifying") where TableB's primary key should be the same as TableA's then I"m not going to have an auto_increment defined for tableB. That wouldn't make any sense. With that said, the way to get the last auto_increment id allocated on a thread is to call mysql_insert_id. So you frequently will see code that references this and uses the returned value to create child rows, setting either all or part of the pk, or foreign key values for subsequent inserts.
  3. Yes I agree, and I planned to write up a news story on the fork and throw in my two cents. I agree with a lot of the changes he has made, and some of the performance enhancements are nice.
  4. Why don't you just force a refresh when they update? Are these additions so frequent that you can justify ajaxing what is typically a completely static list?
  5. The apache error log would have the error most likely. How are you referending the page? Are you using http://localhost/yourscript.php?
  6. http://php.opensourcecms.com/scripts/show.php?catid=3&category=eCommerce I'd suggest you take a look at opencart.
  7. Please use code or php tags for any future code submissions you have. I'm not sure what problem you are having right now, I don't see any problems with the code. Are you getting an error?
  8. Unless register globals is on, which hopefully it is not. $sql="UPDATE $tbl_name SET category='$category', productname='$productname', price='$price' WHERE image_id='$id'"; All of these variables need to be gotten from the $_POST, as alluded to bey WebStyles.
  9. I don't see anything that jumps out at me as wrong. An update can "succeed" even when it doesn't actually update any rows. So long as the update is valid, it will run. You can see if there were any rows actually updated with mysql-affected-rows You should also note this:
  10. You can go into and out of php blocks anytime you want. $head = "Welcome to my site."; ?>
  11. Totally up to you. If the structure is fixed, you can also just specify the names ala: $first->second->desc. Often what is being done with desc would be : Glad you got a solution. isset might be helpful as well, although I didn't test it.
  12. You can foreach through a structure multiple times. The first time you foreach through, assemble a list of the itemids you need. One method could be to do: $items = array(); foreach($resp->ItemArray->Item as $item) { $items[] = $item->ItemID; } I'm not familiar with the api, but you should be able to figure out how to use this to send it to GetMultipleItems.
  13. These are all parent/child groupings. When you ask for the children of first, there are two: this is the first ... Then you try and echo out $second->desc. Your first element is the desc itself, and of course when you reference what in essence is $first->desc->desc, you get an empty result, because there is no child element of that name. Hope this clarifies it for you.
  14. My best guess is that in rc_sent_items_table, there is a row which has a profile_id_to, that has no corresponding match to a rc_profile_table.id value.
  15. paulus, Sorry don't know about any sites that describe something like that. I have done a lot of db design in my career, so I know the rules and techniques for approaching design. There are some good books you can get to help you. I've heard good things about these books, although I realize that they are in english, and I don't know if that's a major impediment for you or not: http://www.amazon.com/Modeling-Essentials-Third-Graeme-Simsion/dp/0126445516/ref=ntt_at_ep_dpt_1 or http://www.amazon.com/exec/obidos/tg/detail/-/0932633188/qid=1070731645/sr=1-1/ref=sr_1_1/002-0849587-1157654?v=glance&s=books Unfortunately books like this tend to be costly, due to the limited market for them. Once you have a solid understanding of the basic rules, you can create a data model to handle any requirement, however there is an art to it, and no shortcut other than experience. I designed lots of systems and worked other developers who understand data modeling, and could challenge my designs.
  16. This thread has lost steam at this point. Speaking generally, if you need just the rows for a certain id, and nothing else, then that would go in your where clause. Then when you fetch all the rows using mysql_fetch_assoc you'll have them all for display or adding to an array. If you're pulling out more than just the one id, but you want to display them in groups, then you would use ORDER BY id, and you would have to use a variable to detect inside the loop when an id had changed. Simple to do. Either way, I think at this point you should try and make a new thread describing what you're trying to do and include any code you have.
  17. It's just something you pick up over time, and get a feel for which types of loops to use. Here, you have 3 different options that control the way the string is padded, so building that around a switch statement for each case tends to keep the code simple and clear. The same thing could be done with a big if-then-elseif statement. For loops are good when you know exactly how many times you need to run through something. While is good for when you need to loop until a condition is met (like fetching some unknown number of rows from a sql result set.) Try not to get caught up in being overly concerned that you're "doing it wrong." The worst thing that happens is you write bad code, and even writing bad code is going to teach you a lot.
  18. This syntax is just completely wrong. $connect->query("INSERT INTO `user` (`username`, `password`) VALUES ({$CreateUser['username']}, {$CreateUser['password']})"); You don't have a variable $CreaterUser, you have a class, and you made an instance $newUser. You need to use that instance to access the variables. $connect->query("INSERT INTO `user` (`username`, `password`) VALUES ('$newUser->username', '$newUser->password')"); Yes, I could rewrite things the way Thorpe is suggesting, and that would be good, but I think you need to get clarity on how php oop works before you start trying to understand dependency injection
  19. Well in the code you have you make a mysql class instance and call it $connection, and then you call $connection->connect(...); Alll good there. But then you seem to forget about that and make a new instance of the mysql class, and you don't connect, but try and query with it. Just use the $connection you already made previously. While we're picking at problems your insert syntax is way wrong. There is a weird SET= syntax but I don't recommend that at all. The syntax you should use is: INSERT INTO TABLE (column) VALUES (value) Your statement would be: $mysql->query("INSERT INTO `user` (`username`, `password`) VALUES ({$CreateUser['username']}, {$CreateUser['password']})"); However that doesn't in any way match your classes or the code you showed before. It might give you insight into the syntax at least.
  20. You probably want to take a look at this: $this->passowrd = $db_password;
  21. In a nutshell: Databases: Pros: Easy to change values with a web frontend, other things can also get/set the data Cons: Adds overhead, requires code to interact with it Agree with Requinix here. Books have been written about this. Usually with a db you are looking for flexibility and ease of addition through a UI. If this is highly static data as is most everything you describe you don't want to have to makeup db lookup calls all the time, but you can mitigate that with caching. See -- just about every cms.
  22. The way browsers work is defined by the HTTP protocol. At its most simple, it's a request/response system. Browser requests page -> Server replies with response. This happens as quickly as possible, and as soon as the last bit is sent the server closes the socket connection, at least in a logical sense. Page requests occur in response to user activity (entering a url, clicking on a button or link) and by design there is no sustained connection or session possible. Cookies were the first attempt to provide a mechanism to get around this lack of session. At the point that a page has been delivered based on information pulled from a database, that information is inherently old. If one second later someone changes the database, there is no way that will reflected in the static html page I'm looking at in my browser. Ajax is a fancy name for what is a simply facility that was added to javascript (originally by microsoft) allowing it to make connections from the browser to the server using javascript code. So you can set up a connection to sit and poll fairly frequently, and in that case, you would be able to detect that data had changed and update the screen via javascript. There is also a technique people call "long polling" that takes a slightly different approach and in some cases is a better solution than frequent polling. This does a great job explaining it: http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/
  23. It's entirely up to you. Either solution will work, and each has strengths and weaknesses.
  24. With sprintf the %s you embed gets replaced with the value of the parameter you provide, while also being conformed to the formatting specified. '%s' just specifies that it needs to be a string, so I don't see a lot of value to using it here over using concatenation. Done what Zanus suggests is not a bad idea, because you can var_dump($q) and see if it's a valid sql statement if you want, however your main mistake as he also pointed out is that with updates there is no VALUES keyword. You do SET columname = the_value And if you have multiple columns to update SET columnname1 = a value, columname2 = another value, etc... If your syntax had been correct it would have worked even doing it the original way you had it.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.