Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. If you do enter the right password then, with the correct code, the answer will be isset() but it won't not-match the answer (ie, it does equal the answer) and the branch won't execute.
  2. Using [][] will just tell PHP to create a new value inside a new array inside the variable. Put the key_name inside the source array before you merge it into $services. At least I think that's what you want. As for why your last bit of code doesn't work, foreach will create copies of values. $key is a copy of something in $service. You can go ahead and add whatever you want to it but you'll only be modifying the copy. It's possible to make it not copy but that's not the best solution (if it would work anyways, I didn't think it through) in this case.
  3. That entering anything at all as the answer will trigger that branch to execute. Given that the message is about entering the wrong answer, shouldn't the condition check to see if you entered the wrong answer? Hint: you do it a couple lines lower.
  4. Looks like the answer is "blue"? Take a look at what you wrote: isset($_POST['answer']) && $_POST['answer']!=''Say I enter "blue". Is the answer isset()? Yes. Is the answer not empty? Yes.
  5. In a form that's actually readable, <?php $con=mysql_connect("localhost","root","duane"); // Check connection if(!$con){ echo ("Could not connect." .mysql_error()); } echo ("Connected successfully"); $selected = mysql_select_db("dummy") or die ("No existing database".mysql_error()); mysql_query($selected,"INSERT INTO prepurchase (ID, Sum, Reply, items, time) VALUES ('080392',15,1,'2m2','5:46'')") or die(mysql_error()); mysql_query($selected,"INSERT INTO prepurchase (ID, Sum, Reply, items, time) VALUES ('080390',20,1,'2m3','9:46'')") or die(mysql_error()); $data = mysql_query($selected, "SELECT * from prepurchase") or die (mysql_error()); while ($row = mysql_fetch_array($data)) { echo "FN: ".$row{'Firstname'}." LN: ".$row{'Lastname'}." Age: ".$row{'Age'}."<br>";//display the results } mysql_close($con); ?> Read the manual page for mysql_query() to see how the function should be used. Spoiler: you're close. Also, echo "FN: ".$row{'Firstname'}." LN: ".$row{'Lastname'}." Age: ".$row{'Age'}."<br>";//display the results {} array syntax is deprecated. Use []s instead.
  6. More background information? Where is $decoded_data coming from? Maybe there's already functionality you can use to do this.
  7. MySQL doesn't support the regex syntax you would need for this, and running all the data through PHP would be crazy. Any alternatives?
  8. Also the documentation for include() explains the logic used. Unless the change was for the better.
  9. Why at all, even? Can't have asterisks in filenames.
  10. The homework is due today. Between here and Dev Shed it seems you need more personalized attention than we can give over the Internet. I suggest you set up an appointment with Mr. Shafer (apparently he's appointment only 12-1pm) and turn in the assignment a day or two late. But be sure to turn it in within a week: you'll lose many more points if you don't submit it at all.
  11. URLs don't matter as much as some people think. Rearranging the data into a different form (?action=rug_delivery to /rug_delivery) won't give as much an improvement as if you were adding new data (?node=123 to /123/rug_delivery). That said it's still a good idea to do it. The underlying structure is decent enough, and the idea of running everything through one file (in one form or another) is pretty standard. If you arranged files in a certain way you could probably do away with switch statements in favor of dynamically locating files to run - ?action=rug_delivery could map to /pages/rug_delivery.php - but you'd need to make very sure that's done safely. Eventually the site will grow to a point where you'll feel it necessary to redo things. That's good. When that time comes you'll have a better understanding of how the site needs to operate and can rebuild all the new stuff you've come up with in a more "proper" way.
  12. I imagine it would have fixed most, if not all, of your problems since you're using completely different code. is_numeric() wants something to check. If you tell it to look at the string "text" then it's going to respond with "no, that is not numeric".
  13. It's an evolving language. It's not like you can expect HTML 5 to behave the same way as HTML 3, right?
  14. call. user. func. array. [edit] When you use that for bind_param() then you have to build the array by-reference.
  15. Looks right to me. Depends. What is it supposed to mean? What is it used for and where does it come from?
  16. Actually call_user_func_array() that trq mentioned does exactly what you need but you do have to pass it a "load of values bundled into one parameter"
  17. You mean if you want to pass those same unknown number of arguments to another function? Like func($args[0], $args[1], $args[2], ...)
  18. Don't use $row['rank'] and just count it out yourself. $rank = 1; // while { // print everything using $rank as the rank $rank++; // }
  19. It's more like the second one, but make sure you aren't using smart quotes. $products_description = tep_db_prepare_input($data_row[1] . ' ' . $data_row[2] . ' ' . $data_row[3]);
  20. Make sure you don't call getRating() with a third argument that equals zero. Or edit the function so that it handles the $click==0 case gracefully.
  21. He's saying that the "one image" you embed is picked randomly.
  22. Please use [php] or [code] tags for your PHP code. Striving for no syntax errors is really great, but you should avoid warnings and notices too. Your script has a few of them. $_POST is a variable, not a function. if (($_POST[val1] == "") || ($_POST[val2] == "") || ($_POST[calc] =="")) - If I haven't submitted the form yet then $_POST will not contain anything. You should check that these things actually exist before trying to use them. - For anything other than a trivial if block you should use {}s. if (($_POST[val1] == "") || ($_POST[val2] == "") || ($_POST[calc] =="")) // and almost everywhere else you use $_POST val1, val2, and calc are not constants. If you want strings then you need to use quotes. if ($_POST["calc"] = "+") { Count your equals signs.
  23. That won't work. The \\ becomes \ inside the string and the pattern is/^(C:\)[[:print:]]$/resulting in an unmatched (. '\\\\' will turn into \\ and a literal backslash.
  24. Anecdotally, the rules for finding pathless files with include() has varied over time and PHP versions: sometimes it might search the directory of the parent file, sometimes it only looks at the working directory. The best thing to do is be very explicit with your filenames by using absolute paths. For something relative to the directory of the parent file you can include __DIR__ . '/firstfile.inc.php'; // PHP 5.3+ include dirname(__FILE__) . '/firstfile.inc.php'; and for something relative to the root of your website, include $_SERVER['DOCUMENT_ROOT'] . '/includes/firstfile.inc.php';
×
×
  • 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.