Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. Based on your existing code I would say that it is working as designed. You are using javascript to take a drop down list and use that to add li's to an unordered list. An unordered list is not a form element, thus when your form is submitted, the ul is not sent. You probably want an extra routine that copies the li's to a hidden form element which has an array structure. In short, you need additional javascript to continue with the design you have now.
  2. Correct. echo requires a string, but as php is loosely typed, you can echo any of the basic types. You can not echo compound types like arrays or objects. If however, your class has a method that returns a base type you can echo that: echo $myobj->somefunction(); magic methods like __toString have special behavior, but in terms of writing them, they are just like any other method, only they are required to have a special name.
  3. Some code like this is what you want: $numbers = explode(',', $searchText); foreach ($numbers as &$number) { // make sure you don't have any spaces in the string $number = trim($number); if (is_int($number) && strlen($number) == 4) { echo "$number is ok"; } else { echo "$number is not a 4 digit number"; } }
  4. I don't see anything specifically wrong, however: the file upload depends on xhr2 support in the browsers, and IE does not support xhr2. They author claims to provide fallback to iframe, but this is something you'd obviously have to test extensively if IE support is important to you. While your settings look ok, you should check phpinfo to determine whether those settings are actually reflected in your running webserver the upload not reaching 100% seems to be a design flaw, in that that the upload is completed and the request completed before it updates the client ui to display it. I don't know that you can fix that, or that it's a problem worth fixing.
  5. You need to post the code for inheritance.php. From the looks of the error, you are probably trying something like: $newcar = new Newcar(); // Sometime later echo $newcar; echo expects a string, not an object. As an alternative you can try var_dump($newcar), if you just want quick and dirty debug output while you are learning. It is also possible to implement the php magic method __toString in your class, which will allow you to echo or print an object of your class, but that requires you to write the code that provides something "printable".
  6. Those are not arrays, they are strings. Your question is far from clear. Does a particular number have to be exactly 4 digits or can it be from 1-3 digits long? What is the output you expect?
  7. Why didn't you say so previously! Your linkage really does make ALL the difference. Well played sir!
  8. I'm not really clear on what you're talking about. There's loop devices which are used in Linux to accomplish various things like creating virtual filesystems inside of files for use in virtualization, or of course there's the network Loopback device. Neither of these seem applicable to Shared hosting, which is facilitated by the sharing of an IP address amongst numerous sites via HTTP 1.1 named based vhosts. If you have a link to someplace where this restriction is explained, I might be able to offer some ideas as to what they might be protecting against, but the terminology you employed in describing the issue doesn't ring a bell.
  9. Troll say you. Bot say I. Either neither both. Artificial experiment lacking senses, coherence pointfulness. Complete idiots, you must think that we are. Our friendliness and tolerance should be confused with weakness not. Crush you if you continue to play these silly games, we will. With pranking some other community seek the path of enlightenment that comes, or better yet, of a life if you must get some semblance.
  10. Hey Jaysonic, good to see you, even if it's just a quick hello.
  11. What KevinM1 was suggesting is that you pass your dependency (A database connection object) into the table specific models. Since those classes won't work without the database connection, it probably makes sense to pass it as a constructor parameter: $foomodel = new FooModel($db); Now one way to make this work well is to bake in a registry object into your controller class, where you will be making models. Or you could make it part of the controller class, perhaps as a base class, so that it is automatically something you can get access to in any controller, ala: // In controller $fooModel = new FooModel($this->getDb()); Let's say that all your controllers implement a base controller class -- then you simply have your getDB() check to see if it has a database connection object stored, or if not, creates a new one.
  12. Yes, that is the way most websites of any competency work. You have a variety of scripts (or controllers in mvc) that tend to do one thing, or several things based on the paramters that are sent to them. In your case, probably the easiest path is to write a script that displays the single page, exactly as you showed in your example: mysite.com/products.php?id=3 And in that script you'd get the value from the $_GET superglobal $id = (int)$_GET['id']; if ($id >0) { // do your database lookup by ID, and display the information } As for having a search friendly url, yes you could use mod_rewrite to setup a rewrite rule, so that the url's you present, and accept are actually in the form of: mysite.com/products/44 A typical rewrite rule would look like this: Options +FollowSymLinks RewriteEngine On RewriteRule ^products/([0-9]+)$ products.php?id=$1 There are scores of tutorials around on creating a simple mod rewrite rule that will configure your apache site by adding the rewrite rule to the .htaccess file of your root directory. Keep in mind that anyplace you render a link to your own products, you must render the /mysite.com/products/44. People are often confused about how rewrites work. They work on people who are trying to access your site, and don't translate the links you output in your scripts on the fly.
  13. It seems you may have forgotten to put on your special hat this morning....
  14. Well deserved by one of the legendary php stalwarts. You know if josh is composing verse in your honor you have to rock.
  15. We're really good guessers, but in all honesty, i still really don't know what you're asking for. You really need to provide the structure of your tables, and a better description of what you are trying to do, why, and how you are trying to do it. In particular this quote is inscrutable: Part of the problem is that you don't seem to understand the right terminology to use. I have no idea what you mean when you write "its done by creating a line up to". What is "it" and what does "done" mean? "deleting" in this context means deleting what exactly? It's all as clear as mud. Relational databases work on set theory, so there is no inherent concept of a row number. Result sets are inherently unordered until the point that you apply an order using ORDER BY. You can simulate row numbers procedurally, or using database engine specific mechanisms like LIMIT, but those concepts are only good for the lifetime of a single query. If you need to persist data beyond that, those concepts aren't usable. If I have 3 rows of fruits (apple, orange, pear) and you think of those as (1,2,3) what happens to your row numbering scheme when I insert "banana"? If you have code that tried to reference 2=orange, that code is going to be badly broken. As far as we can see you have a user table and a bank table. That is about all we know right now. It appears you want to establish some sort of relationship between a user and a bank. At one point it appears that your user table had a location, and you used that to associate a user with a bank? You have provided only snippets of code that are completely out of context and missing key pieces of information. I'm not doing you any favors by not stating outright, that your question asking skills as demonstrated in this thread are severely lacking in the area of clarity and specificity. I've put way more effort into this thread, in pointing out how vague and incomprehensible your questions and elaborations were, then you did in asking the question in the first place, and that needs to change if you want to get anywhere in this process.
  16. Everything Dan stated is completely right. However, at the end of the day, the main point of using the ereg or preg functions is to perform pattern matching against strings using regular expressions. Regex is just so damn nifty and useful for text pattern matching, that there are regex libraries for just about every language. There are a number of really good books out there on regex, but there are also some great online resources like www.regular-expressions.info.
  17. Sorry, but no, it's not clear what your question is, because we don't really know what the structure of your database looks like. I'm going to just take a guess that the bank table has 1 row per bank. If that is the case (and what you're doing, is completely wrong, if it is not), then rather than doing a set of hardwired queries for each bank, you should simply be doing a single query that gets all banks other than the user's originating bank. Then you can use that result to loop through it and output your select box: $transferBanksResult = mysql_query("SELECT * FROM `bank` WHERE `location` != '$fetch->location'"); if ($transferBanksResult) { $rowcount = mysql_num_rows($transferBanksResult); if ($rowcount > 0) { $rand = rand(1, $rowcount); $rowid = 1; echo '<td bgcolor="#555555" align="left"><select name="whatbank" class="select_box" id="whatbank" style="width:250px" title="The bank to transfer the funds with.">'; while ($row = mysql_fetch_assoc($transferbanksResult)) { $option = '<option value="' . $row->id . '"'; if ($rand == $rowid) { $option .= " selected"; } $option .= ">$bankle->bank($bankle->commission %)</option>"; echo $option; $rowid++; } echo '</select></td>'; } }
  18. I'm sorry if that is the impression I gave. You're code is not at all bad for a beginner, and it takes time to figure out the way to approach particular things. Certainly, I have questions about why you do certain things in your code, and I hope that I demonstrated the "DRY" concept -- try and find places where you are basically doing the same code repeatedly, varied only by one or two variables, as in the case of the html selects, and see if you can reduce those to a single function, that can then be used instead of the same 5-10 lines of code. I've been doing database work for a looong time, so I find it hard to resist pointing out designs that aren't optimal, but the truth is, that for small to even medium size databases the efficiency of the design is not all that important.
  19. Haha Dan, we very nearly posted the exact same thing -- i guess I should have looked at your pending post, but I'm far too lazy once I typed something in, to actually check first.
  20. The top of your script instead of having if ($submit) you need something like this: if (isset($_POST['submit']) { This is the reason that your code currently seems to do nothing -- it never reaches the computation portion because $submit is not set to anything. When you do a form post php makes the values of the form available in the $_POST superglobal. Please read up on that to understand more.
  21. This-- not to mention you don't want to use a header location redirect. A simple self posting form that checks that the form was submitted, will work properly. You simply execute your decrement when the form is submitted at the top of the script, only when the form is submitted. If you want something fancier, you could use ajax to handle the decrement of points, and returning of the latest count, but I'd recommend highly the use of jquery if you want to go down that route.
  22. I think that is your problem Tables are for tabular data, plain and simple. If the data is tabular in nature, then a table is appropriate. Using tables to create layout is not the way to go -- that is the realm of css. There are sites like this one that show you how to do just about every variation possible.
  23. That is not a class -- it is the requirements for a complete application.
×
×
  • 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.