Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. Because that's the way that valid html works. Regards Huggie
  2. Use the function nl2br() Regards Huggie
  3. $page['listing']['desc'] contains some "\n" characters (newline) which aren't displayed in HTML, but are in <textarea> tag. Regards Huggie
  4. Cooldude means creating a database table by clicking buttons in php rather than in mysql directly. I wasn't aware that this was a faux pas in PHP and would imagine that it's something to do with security, but this should be no more insecure than doing it in mysql directly so long as you put the appropriate measures in place. Regards Huggie
  5. You can still use the button tag, but just make sure it's inside the form tag. Regards Huggie
  6. php is case sensitive, so you'd need to change this <input type="submit" name="CreateDB" value="create db"> to this <input type="submit" name="createDB" value="create db"> Regards Huggie
  7. Try putting the buttons inside the <form> tag, and also change them to submit input types. Regards Huggie
  8. Try changing this: mysql_query($sql,$con); to this: mysql_query($sql, $con) or die("Can't execute sql" . mysql_error()); Regards Huggie
  9. Oracle doesn't have the concept of a LIMIT clause, so your syntax is incorrect. Regards Huggie
  10. Use an underscore (_) it's the SQL wild card for single character. SELECT column FROM table WHERE column LIKE '12_' Regards Huggie
  11. I think I'd use the cURL library for this one, or maybe sockets as they'll probably give you better control over your requests. Regards Huggie
  12. I'd go for a database table with the comic strip details (including a datetime column to take the details of when the image should go live). In PHP I'd do a query like so... <?php // Get the current time in seconds from epoch $current_time = time(); // Run a query in the database $sql = "SELECT comic_image_path, unix_timestamp(go_live) AS gl_ts FROM comics WHERE gl_ts < $now ORDER BY gl_ts DESC LIMIT 1"; $res = mysql_query($sql) or die("Cant execute: $sql" . mysql_error()); $comic_path = mysql_result($res, 0, 0); // Output the comic echo "<img src='$comic_path'>\n"; ?> This way you could insert comic image details into the database with a future go_live date, and each time the page loads it would check if it's getting the latest 'live' image. I hope this makes sense. Regards Huggie
  13. Probably, but I'd have thought that would have been better posted in a JavaScript forum It's simple enough in php by using variable variables Regards Huggie
  14. I think the biggest consideration here would probably be bandwidth. Do you have a bandwidth allowance on either server, what's the performance like on each of the servers, how quickly does the first one respond to the second ones requests etc. It's always got to be preferable to retrieve images locally. Rehgards
  15. CHMOD won't work on a Windows OS. Regards Huggie
  16. I find using list() normally more appropriate for just splitting once... <?php $word = 'cabbages_green'; // Now assign the word parts to new variables list($veg, $colour) = explode('|', $word); ?> Regards Huggie
  17. You can assign a value to it like this: $_SESSION['last_access'] = now(); Regards Huggie
  18. And what was the echo output? Regards Huggie
  19. If the file starts to get really big then you'll probably want to change it to use fopen() and fgets() rather than just file() or better still, consider a database. Regards Huggie
  20. Sorry, Missed off a closing bracket. Try this (tested and working)... <?php // Check the error code if ($_FILES['uploaded']['error'] == 0) { // Is the current directory writable if (is_writable(dirname(__FILE__))) { // Just use the file name and save in the current location $target = basename($_FILES['uploaded']['name']); echo "Trying to move " . $_FILES['uploaded']['tmp_name'] . " to " . $target; if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "File moved OK"; } else { echo "Couldn't move file"; } } else { echo "Directory isn't writable"; } } else { echo "There was an error uploading the file"; } ?> Regards Huggie
  21. I'd go with something like this (untested)... <?php // Open the file and read the details into an array $data = file('counter.php'); // Change the array so that it's keyed on IP and the value is the hits foreach ($data as $d) { list($ip, $hits) = explode('|', $d); $new_data[$ip] = $hits; } // Check if the ip already exists if (in_array($_SERVER['REMOTE_ADDR'], array_keys($new_data))) { // If it does then increase the hits by one $new_data[$_SERVER['REMOTE_ADDR']]++; } else { // If it doesn't then add it $new_data[$_SERVER['REMOTE_ADDR']] = 1; } // Then here open your counter.php file and write it all back // REMEMBER the data you want is now in new_data, not the original $data ?> Regards Huggie
  22. I'd go with this... $sql = "SELECT * FROM items WHERE country='" . mysql_real_escape_string($targetb) . "' AND type='" . mysql_real_escape_string($_POST['Type']) . "' AND (Abstract LIKE '%$keyword%' OR town LIKE '%$keyword%') ORDER BY id DESC"; Regards Huggie
  23. Are you using some prebuilt forum software, if you are then you can probably guarantee that it's already been done and there's a process for it. If not then it's probably a little more difficult, but not beyond all hope. Are you hoping to put a new forum system in, or just use the old one after a re-design? Regards Huggie
  24. Try this then... <?php // Check the error code if ($_FILES['uploaded']['error'] == 0) { // Is the current directory writable if (is_writable(dirname(__FILE__))) { // Just use the file name and save in the current location $target = basename($_FILES['uploaded']['name']); echo "Trying to move " . $_FILES['uploaded']['tmp_name'] . " to " . $target; if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "File moved OK"; } else { echo "Couldn't move file"; } } else { echo "Directory isn't writable"; } else { echo "There was an error uploading the file"; } ?> Regards Huggie
  25. You probably wouldn't but as the OP has only made 6 posts in total, they're probably new to PHP hence the hand holding initially. It's a gradual process. Write the code to put the data into the database. Realise that you get errors and someone's submitted a string in a number field. Write the code to correct the above (validate). Realise the code inserts but that someone's spamming you. Write the code to prevent automated submission. When you're new to PHP you don't automatically think about these things. All I'm saying is that even if you're not going to offer any help yourself, a link to a post that might help would certianly be more appreciated. Regards Huggie
×
×
  • 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.