Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Look at using array_diff and array_merge functions.
  2. Not quite you appear be using smart quotes here </tr>”; The ” should be a " You placed the </td><td> in the wrong place it needs to go before $item </td><td> $cost</td></tr>"; Your code should be <?php $names=array('duck','chicken','turkey','axolotl'); $prices=array(7,5,18,200); print "<table> <tr> <th>Select</th> <th>Animal</th> <th>Price</th> </tr>"; for ($i=0; $i<=3; $i++) { $item=$names[$i]; $cost=$prices[$i]; print "<tr><td><input type='radio' name='purchase' value='$i'> </td><td>$item </td><td> $cost</td></tr>"; } print "</table>"; ?>
  3. It is asking you to modify the table so it includes the table headings Select, Animal and Price To add the table headings change print "<table>"; to print "<table> <tr> <th>Select</th> <th>Animal</th> <th>Price</th> </tr>"; Then add </td><td> before $item
  4. Change $dbname to $database in dbstuff.inc
  5. Your code is not connecting to the MySQL database properly. The mysql server is not allowing the admin user to connect the database on localhost. How have you setup the admin user?
  6. Because you do not have any logic in your code to stop the script from running the insert query if the form fails your validation tests
  7. Looking at the source code for your site I am guessing you are using wordpress with the woocommerce plugin? Googling woocommerce shipping class results in this http://docs.woothemes.com/document/product-shipping-classes/ Maybe you set a custom shipping class and that is what is being output. WooCommerce has a vast API knowing which specific place you need to edit we wont know. You are best of getting support from woocomerce themselves.
  8. Because you are only incrementing the $not_archived variable when the current news item's archived field is set to N ($newsitem['archived']). The var_dump you posted contains two news items and both have the archived field set to y.
  9. @LauraL19 use the following instead $result = mysqli_query($cxn, $query) or die ("Query died: category - " . mysqli_error($cxn));
  10. The query is returning all records where the patient's id_number matches the id_number in the medical_aid table. So if a patient has two or more records in the medical_aid table you'll see their name, surname and id printed two or more times in the table, but the medical id and medical scheme will be different. If you only want to see the patients name, surname and id printed once but have their medical aids listed then you'll need to add more logic to your while loop when displaying the patients records
  11. If you are doing that you don't want to be storing any punctuation characters for the url. You'll want to do something like this $post_url_title = str_replace(' ', '-', strtolower($post_title)); // convert to lowercase and convert spaces to dashes $post_url_title = preg_replace('~[^0-9a-z_-]+~', '', $post_url_title); // strip out any punctuation characters So the urls for your posts can only contain letters, numbers, underscores and dashes.
  12. How is this PHP code being called? I am guessing this is part of an Ajax request?
  13. Did you also add that code to the editform too? What errors are you getting?
  14. What! You dont put the code I suggested into dbstuff.inc. You replace this code (lines 60 - 61) in Category.php $result = mysqli_query($cxn, $query) or die ("Query died: category"); with this $result = mysqli_query($cxn, $query) or die ("Query died: category - " . mysqli_error()); Post the error message here.
  15. Sorry, I mistyped the link in my previous post it should be http://php.net/mysqli_error Change $result = mysqli_query($cxn, $query) or die ("Query died: category"); to $result = mysqli_query($cxn, $query) or die ("Query died: category - " . mysqli_error()); What is the error?
  16. Ok I see your are requiring that file in manger.php. But I don't see you're including that file in the login page code you posted here. Is that just part of the code for the login page?
  17. Did you read reply #5 above? Before pasting your code using Ctl+V type [/nobbc] then clicking the Paste as Plain Text icon and then type [nobbc] . Does that make a difference?
  18. The following query is failing most probably due to an error $query = "SELECT DISTINCT category, type FROM Furniture ORDER BY category, type"; $result = mysqli_query($cxn, $query) or die ("Query died: category"); To see what the error is call mysqli_error().
  19. They will be querying the database and returning the record that matches the url for the article/page. You can of course do this too if you so wish. If you want to go this route then add an extra column in your table that holds the url for the post. You'd then change your query to something like $post_url = mysql_real_escape_string($_GET['title']); mysql_query("SELECT post_id, post_title, post_content, etc... FROM posts WHERE post_url = '$post_url'"); The following rewrite rule will match urls like site.com/page-title-here RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z0-9_-]+)/?$ post.php?title=$2
  20. In all pages that uses sessions you must be calling session_start(). I do not see this function being called in the codes you have posted.
  21. The problem is checkbox fields are only contained within the $_POST if they are checked. If they are not checked then they wont be in the $_POST array. If you used neil.johnson suggestion correctly you wont need to add a hidden form field.
  22. Yes you can do this. However in the url I'd contain both the post id and the post title, like how this forums url are (the 283442 is the topic/post id and the text after it is the topic title). That way the your existing code that gets the post from the database doesn't have to be changed. The only the code needs changed is when you make the links. For example you have code like the following for outputting post links like site.com/post.php?id=123 echo '<a href="site.com/post.php?id='.$post_id.'">'.$post_title.'</a>'; To have links like site.com/123-the-post-title. You'd use something like the following for outputting the formatted links $post_url_title = str_replace(' ', '-', strtolower($post_title)); // convert to lowercase and convert spaces to dashes $post_url_title = preg_replace('~[^0-9a-z_-]+~', '', $url_title); // strip out any punctuation characters echo '<a href="site.com/'.$post_id.'-'.$post_url_title.'">'.$post_title.'</a>'; // output formatted url The following rewrite rule will capture these urls and call post.php RewriteEngine On RewriteRule ^([0-9]+)-([a-z0-9_-]+)/?$ post.php?id=$1&title=$2 In post.php you'll still get the post id using $_GET['id']. To get the url formatted post title you can use $_GET['title'].
  23. Your check_input() function is encapsulating values within single quotes and you are also encapsulating each value in the query with single quotes too. In affect your values in the query are wrapped in single quotes twice. This is what is causing the error. To fix the error change $value = "'" . mysql_real_escape_string($value) . "'"; to just $value = mysql_real_escape_string($value);
  24. Sorry I do not understand your question/problem. Could you explain what you are trying to do.
  25. Change line 1244 to (isset($_SESSION['uUserTypeID']) && $_SESSION['uUserTypeID'] == 2)
×
×
  • 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.