Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. You have included the file containing the function getuniqueorderid() more than once or you have 2 functions with that name. This is not allowed. The error message is telling you where the function is declared.
  2. All you really need is mysql_real_escape_string() when inserting data. You may also want to use strip_tags() to remove any HTML that a user may try to include in a field. I tend to stay away from addslashes() and stripslashes(). Really your filtering should be dependent on what data you expect from the user input. i.e. Should it be a number, should it be a date, should it be an email address, etc If you properly validate your data you wont end up with crap in the database. Garbage in = garbage out
  3. Sorted. Heres how I did it if you are interested: $string = "chester is a county city in Cheshire, England, located in what is named the English Northwest. chester lies on the River Dee, a water body that borders Wales."; // explode each paragraph // each empty array value is a line break (carraige return) $paragraphs = preg_split('/\\n{1,}/', $string, -1, PREG_SPLIT_NO_EMPTY); // loop through each paragraph and explode the sentences for($x = 0; $x < count($paragraphs); $x++) { $stringParts = explode(". ", $paragraphs[$x]); // loop through each sentence and capitalize the first letter for($i = 0; $i < count($stringParts); $i++) { $stringParts[$i] = ucfirst($stringParts[$i]); } // implode the string parts back into sentences $paragraphs[$x] = implode(". ", $stringParts); } // build back up the new string foreach($paragraphs as $paragraph) { $newString .= strlen($paragraph) ? $paragraph : "\n"; } print nl2br($newString);
  4. Thats the theory I cam up with but its a pain in the arse to keep the rest of the text formatted.
  5. That will only format the first charater of the text. Needs to be all sentences/paragraphs in the entire string (could be a whole article). Also do not want to convert to lowercase, lets say the text had NASA in it. Dont want it coming out as nasa.
  6. Anyone know of a library that can take in a string and auto-format the sentence structure. i.e. Original ========= this is a sample sentence. this is another sample sentence. this is the start of a new paragraph. New ========= This is a sample sentence. This is another sample sentence. This is the start of a new paragraph.
  7. Unsure, im not really a graphics person. I exported the image as a PNG 24 using Fireworks. 595px x 31px to fit landscape on A5 PDF.
  8. By style im guessing you mean i.e. colour, size, etc (different product options) If the styles are related to the productId then add the styles in a sub array i.e. $_SESSION['cart'][1] = array('name' => product xyz, 'qty' => 2, styles => array('red' => 1, 'blue' => 1)); So the user has added 2 of product xyz to the cart,1 red and 1 blue. Have you inherited this code from somewhere as the cart model seems sound and the fact you are struggling suggests this. If I were you I would break down each user action into smaller steps and tackle each one i.e. User adds item to cart - 1. Check the product is not already in the cart, if so increment the quantity. 2. Send user to basket page 3. Display cart contents User deletes item - 1. Retrieve product from cart and decrease the quantity. If quantity is 1 remove the product 2. Send user to basket page 3. Display cart contents User logs in - 1. Obtain guest session cart contents and transfer to database storage referenced by the user id If you struggle with arrays or sessions then do some tutorials or reading up.
  9. visit your routers IP in your browser You are confused. The post is not about modifying a routers configuration but the IP address of a physical machine. If you want to change the server settings remotely use PUTTY. You do not need PHP to do this.
  10. The current session storage method using sessions is fine. In terms of quantities you just need to check if the product Id already exists as an array key. If so increment the quantity key by 1 // the product is added to the cart via a form post $productId = $_POST['productId']; // check if it exists in the cart if(array_key_exists($productId, $_SESSION['cart'])) { // update the quantity $_SESSION['cart'][$productId]['quantity'] = $_SESSION['cart'][$productId]['quantity']+1, } else { // add the new product to the cart }
  11. Yes. Try your rewritten URL.
  12. RewriteRule ^whois/([a-z0-9\.-]+)$ /whois.php?query=$1 [L]
  13. Looks a bit of a cut and paste job! How do you want to improve it?
  14. If the variable is numeric: RewriteRule ^somepage/([0-9]+)$ /somepage.php?variable=$1 [L] Check the mod rewrite forums for extra info http://www.phpfreaks.com/forums/index.php/board,50.0.html
  15. The forum categores are stored in a database table, correct? Simply use a database query to backtrack the path from the current category and display the results on the screen.
  16. Try out the modified code on a test page and see if that works as expected.
  17. Using a loop. Not sure why you want this though, data is better in array? for($x = 0; $x < count($_SESSION['cart']); $x++) { ${"product".$x} = implode(",",$_SESSION['cart'][$x]); } print $product1."<br />"; print $product2;
  18. Or you maybe including the same file twice in a script.
  19. The php.ini file will be loading it. Doesnt matter what functions you are using.
  20. That wont make the slightest bit of difference! You are setting an empty session value before the form is submitted using $_POST['name'] Also use the server global for PHP_SELF: $_SERVER['PHP_SELF'] Should be: session_start(); // set the session if(isset($_POST['cmd']) && $_POST['cmd'] == 'Send') { if(strlen($_POST['name'])) { $_SESSION['name'] = $_POST['name']; print_r($_SESSION); exit(); } } $str = '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; $str .= '<input name="name" type="text">'; $str .= '<input name="cmd" type="submit" value="Send">'; $str .= '</form>'; echo $str;
  21. If the IP values get saved to a file then you could do this by reading and writing to the file. The file must have the correct permissions in order to read/write.
  22. This is not true. You can acheive this by using output buffering. Search the forum on this topic.
  23. You have 2 functions with the same name included in your script. You cannot do this, rename one of them.
  24. This means that the libraries php requires haven't been installed or are referenced to an incorrect path on your server. I personally dont work in a Windows environment only Linux but its obvious you must obtain the dll files that your configuration requires. The path for your setup is c:\PHP\ext\php_oci8.dll
  25. Is the file larger than the max upload size set in your php.ini file? Also use a proper mime email library such as PEAR's Mail::Mime for sending email attachments as opposed to using the default mail() function
×
×
  • 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.