Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by cyberRobot

  1. For future reference, if you're not interested in switching editors, you could also run your HTML code through W3C's Markup Validation form here: https://validator.w3.org/ Also note that you may want to review the documentation for the <label> tag. You'll either want to have the <label> tag surround both the label and the input field. If it's not around both, you'll need to use the "for" attribute to connect the <label> tag to the corresponding input's "id" attribute. More information can be found here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label There's an easy way to test most <label> tags to make sure they're working. If you have a label and a text input, for example, clicking the label will put the text prompt (aka flashing cursor) in the corresponding input field.
  2. So...where are you stuck? Do you have a process for converting the XML data into something that PHP can loop through? If not, you may want to try PHP's SimpleXML extension. More information can be found here: https://www.php.net/manual/en/book.simplexml.php As for the human-readable headings, you could try looping through the "Entity" elements, looking for the one where the "id" is equal to "1". Then go on to process and output the remaining "Entity" elements. If you have control over the XML code, it might be better to modify things so the headers are stored using unique tags. That way you can just grab them without needing to loop through all the "Entity" elements.
  3. If I'm reading everything correct, the "create" script is under todolist_demo > public_html > todo. The "create" script isn't able to find your db.php because the following line only goes up one level. include('../db.php'); Basically, you're telling "create" that db.php is in your public_html folder. You either need to use "../../db.php". Or I would actually recommend switching that line so it starts at the document root. I'm guessing "public_html" is your root folder. If that's the case, you could try the following: include $_SERVER['DOCUMENT_ROOT'] . '/../db.php';
  4. In case you have control over how $matches is formatted, you could make this easier on yourself by changing the array to something like this: Array ( [0] => Array ( [sku] => 234567 [price] => $33.00 ) [1] => Array ( [sku] => 999888 [price] => $82.44 ) )
  5. You'll want to switch to PDO or MySQLi for working with the database. The mysql_ functions were removed from PHP in version 7.0. More information can be found in the warning box in the PHP manual here: https://www.php.net/manual/en/function.mysql-connect.php
  6. You could use a loop. For example, $mcptitles = array("Volvo", "BMW", "Toyota"); foreach($mcptitles as $mcptitle) { //your existing code here... } Note that I changed the name of variable that holds the array. That way it should hopefully work with your existing code. Also note that I didn't review your code since it sounds like it's working.
  7. I'm not sure why the first URL isn't working. I built a quick test script and that address worked fine for me. I even tried adding the call real_escape_string(), which I thought might be modifying the URL, but everything worked fine. The second "www.google.com" address didn't work for me. However, it worked fine once I added the protocol: https://www.google.com Side note: real_escape_string() is only designed to escape input for use in database queries. If you're looking to escape text for outputting to the screen, you'll want to look into htmlspecialchars() and htmlentities().
  8. When clicking one of the links, does the URL show the correct ID? If so, then the provided code is working fine. As Barand mentioned, we would need to see the code that processes the clicked ID to display the page. Hiding the ID from the URL will prevent people from doing things like bookmarking (or linking) to the pages being generated by the script. So I wouldn't recommend going this route.
  9. Either way works. Once the exit language construct executes, the script stops. It won't do anything with that next if construct when the "user" SESSION variable isn't set. So using else, in this case, is unnecessary. More information about how exit works can be found here: https://www.php.net/manual/en/function.exit.php With that said, if using "else" makes more sense to you...you might consider "elseif" if(!isset($_SESSION['user'])) { exit; } elseif($_SESSION['user'] !== 'SiteOwner') { exit; } And when you get to the stage of blocking multiple user types, you could potentially do something like this: if(!isset($_SESSION['user'])) { exit; } elseif(in_array($_SESSION['user'], array('SiteOwner', 'SiteAdmin'))) { exit; } Note that the above code is untested.
  10. Have you reviewed the information provided by Facebook here: https://developers.facebook.com/docs/sharing/webmasters/ Note that it looks like they have a debugging tool that you can use, under the Testing Your Markup section.
  11. It depends. What are you looking to accomplish? Do you have any experience with HTML? What method of learning works best for you? There are many books that might help, if you're just getting starting. Or I'm sure there are a number of in-depth tutorials online, if you learn better that way. For what it's worth, I regularly use the HTML help docs found on the following Mozilla website: https://developer.mozilla.org/en-US/docs/Web/HTML They do have a few different guides that could get you started here: https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML
  12. Based on the code provided, $user is only being set if the SESSION variable for "username" is set. If you haven't already, I would check to see what that SESSION variable contains when you're getting the error. It's difficult to tell how you should proceed with the information provided. In the end, you'll likely need to test whether $user is set before trying to use it. How you do that depends on the purpose of the page and how your script is set up.
  13. Those are just sample category names. Yours should be +----+--------------+-----------------+ | id | topic_title | topic_parent_id | +----+--------------+-----------------+ | 1 | Authors | 0 | | 2 | General | 0 | | 3 | People | 0 | | 4 | Celebrities | 3 | | 5 | Historical | 3 | +----+--------------+-----------------+ ...etc.
  14. All you should need is the id, topic_title, and topic_parent_id. Where Barand uses "service", you would use "topic_title". Where Barand uses "parent", you would use "topic_parent_id".
  15. As Barand mentioned, the code (as posted) is technically fine. Just be aware that the missing semi-colon after the line that outputs "Green" may cause errors if you add more code to the PHP block after the final echo statement.
  16. No problem. Glad you got everything figured out!
  17. Does the query return an error? If so, what's the error? Or does the page display "New record has been added successfully !"?
  18. When naming the quantity fields, I would use the row ID from the database as the key that goes between the square brackets. If your "Cherry" product's ID is 5, for example, the input tag for the quantity field in the HTML code would look like this: <input type='number' min='0' max='10' name='quantity[5]' ... That way you don't need to pass the product names and prices with the form submission. And you don't need to worry about the customer trying to change a price on you in the form. Note that the "readonly" flag is very easy to bypass for someone who's familiar with the Console feature built into all the major browsers. After the form is submitted, the ID from the "quantity" array can be used to pull the necessary information from the database. The ID will also make it easier to redisplay the form, because you can access the necessary quantity value with the ID (e.g. $_POST['quantity'][5]). Side note: In case you're not aware, you'll want to use caution with using variables like in the following line: <input type='text' min='0' max='10' name='productName[]' value='$productname' ... Have you tried adding a product name that contains an apostrophe? It's going to cause problems with the form. The problem is potentially worse when that variable contains a value that can be tampered with by the user. See XSS attacks for more information. If you haven't done so already, you'll want to look into escaping variables for output. https://www.php.net/manual/en/function.htmlspecialchars.php
  19. You could potentially try setting a session variable (or cookie in PHP) and reload the page. If the session variable (or cookie) doesn't exists after the page reloads, you could display an error message to the user.
  20. In case it helps, the PHP manual mentions the alternative functions to use in the place of your various "mysql_" calls. You just need to look the functions up in the manual. For example, the following page talks about mysql_connect and the potential alternatives: https://www.php.net/manual/en/function.mysql-connect.php As gw1500se mentioned, the PDO alternative is going to be the way to go. Also note that the following page provides more information about migrating from PHP 5.6 to 7: https://www.php.net/manual/en/migration70.php Of course, there may be other changes you'll need to make since it sounds like you were using an even older version of PHP. Note that there are several links under the "Appendices" heading for migrating from/to different PHP versions. Unfortunately, I don't know if there is a way to merge the different links so you can get all the information at once.
  21. cyberRobot


    Hello and welcome!
  22. Just to make sure, for benanamen's suggestion, you should replace the following line: if(isset($_POST["submit"])) With the line below. Note that I removed the curly / smart quotes around POST. if($_SERVER['REQUEST_METHOD'] == 'POST') I would also add some sort of debug code to see if the if test is working. For example, if($_SERVER['REQUEST_METHOD'] == 'POST') { echo '<br>form submission detected'; Does the script display "form submission detected" after submitting the form? Also, if the script still doesn't work as you expect, please post your most recent code.
  • 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.