Jump to content

zq29

Staff Alumni
  • Posts

    2,752
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by zq29

  1. Sorry, yes, that should be $data[$i] - I really shouldn't copy and paste...
    [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]looks good, but Im a little confused why you want to shop off the end of $query[/quote]Its to get rid of the trailing comma.
  2. The manual would be a good place to start, it can be found at php.net although I normally find it best to just use it as a reference when looking up functions. If your totaly new to PHP, and scripting / programming as a whole, I would suggest you buy a book on PHP and possibly MySQL - Numerous books teach both of them.

    If you are familiar with another language, you may find you can just read the manual and pick up the syntax et al pretty easily as the ideas and fundimentals are pretty much the same as other languages.

    As for making a living from PHP, I'd say it is possible, but you'll find it a lot easier if you know a selection of web technologies, HTML and CSS would be a good start. Once your comfortable with HTML, CSS, PHP and MySQL it might pay off to learn some JavaScript and then transition into some Ajax would be smooth I'd assume - I only know basic JavaScript, learning the intimediate to advanced stuff at the moment...
  3. Tested on my WinXP development machine and working
    [code]<?php
    exec("ping 192.168.1.1",$result)
    echo "<pre>";
    print_r($result);
    echo "</pre>";
    ?>[/code]
    Output:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Array
    (
    [0] =>
    [1] => Pinging 192.168.1.1 with 32 bytes of data:
    [2] =>
    [3] => Reply from 192.168.1.1: bytes=32 time=1ms TTL=255
    [4] => Reply from 192.168.1.1: bytes=32 time=1ms TTL=255
    [5] => Reply from 192.168.1.1: bytes=32 time=1ms TTL=255
    [6] => Reply from 192.168.1.1: bytes=32 time=1ms TTL=255
    [7] =>
    [8] => Ping statistics for 192.168.1.1:
    [9] => Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    [10] => Approximate round trip times in milli-seconds:
    [11] => Minimum = 1ms, Maximum = 1ms, Average = 1ms
    )[/quote]

    [b]EDIT:[/b] I also had to exclude the semi-colon from my exec() line, server would not allow it - forbidden message.
  4. I'm not sure if I understood your post 100%, but what I gained from it was, that you want to build a query but it could have any number of fields - which are stored in an array. Hope I got that correct... Heres what I would do:

    [code]<?php
    //Assuming field names and data are stored in seperate arrays but with the same keys
    $fields = array("name","address","telephone");
    $data = array("Kris","1 High St.","123123");

    $query = "INSERT INTO `table` (";
    for($i=0; $i<count($fields); $i++) {
        $query .= "`$fields[$i]`,";
    }
    $query = substr($query,0,-1).") VALUES (";
    for($i=0; $i<count($data); $i++) {
        $query .= "'$fields[$i]',";
    }
    $query = substr($query,0,-1).")";
    mysql_query($query) or die(mysql_error());
    ?>[/code]
  5. Your servers clock is not set correctly, I'm not sure how you'd adjust this with Apache, but you can add an hour onto your time() like this...
    [code]<?php
    $plusonehour = time() + (60 * 60);
    echo "Now: ".date("H:i:s")."<br/>";
    echo "+1Hr: ".date("H:i:s",$plusonehour);
    ?>[/code]
  6. I have glanced over your code, but have not read it in any depth. You mentioned that sometimes it works, and sometimes it doesn't. Have you tried uploading the same file over and over, or, have you tried this with a selection of different images? If you're using different images, what is it about those images that is different to the images that work? The answer to that may narrow down the problem area in your code.

    Heres a tip for you too, it could prevent you from typing more than you have to in the future:
    [code]/*Force $mimetype to all lowercase with strtolower() so you dont have to match against both upper and lowercase versions of the string.*/
    switch(strtolower($mimetype)) {
        case "image/jpg":
        case "image/jpeg":
            $i = imagecreatefromjpeg($temporary_name);
            break;
        case "image/gif":
            $i = imagecreatefromgif($temporary_name);
            break;
        case "image/png":
            $i = imagecreatefrompng($temporary_name);
            break;
    }[/code]
  7. Might be useful for some companies so that they can only allow access to certain sites for their employees, but then again, it's probably a lot easier to set up some kind of internal proxy...

    I saw something a while back called the PetaBox (I think) which has an array of discs which had a total of 1 PetaByte storage space, I think one of the advertised uses of it was to download a copy of the internet, one of the applications for this was for analysis of some kind.
  8. [!--quoteo(post=363406:date=Apr 10 2006, 08:16 PM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Apr 10 2006, 08:16 PM) 363406[/snapback][/div][div class=\'quotemain\'][!--quotec--]

    hehe... hey, if you really want to just have a free-for-all, break out quake 3 arena or UT2K4... i'd definitely be game then!!!

    Yep! Except I lent my Q3 disc to a friend and never got it back :( Although I still have my UT2004 :)

  9. [!--quoteo(post=363368:date=Apr 10 2006, 06:12 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Apr 10 2006, 06:12 PM) [snapback]363368[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    I would, but my ISP blocks port 80 and won't give me a static IP. I know the static IP can be fixed using dynamic DNS, but the blocking of port 80 pretty much kills it.

    If you really want to do this, I'd suggest doing some research because there are a lot of security issues to consider.
    [/quote]
    Can you not use a dynamic DNS service to route connections through a port other than 80? In answer to the original question - I had a RedHat based server up at one point for testing stuff on when I went to college as I couldn't get access to any servers at the college...

    I have a spare machine that I'm going to install FreeBSD on at some point, I want to get comfortable with the command line as I have a dedicated server based on FreeBSD and I want to learn how to use its full potential. So, yes, I will do soon, but it will not be open to the public.
  10. Please do NOT add a sense of urgency to your posts, it is against forum guidelines, you can however do this in our freelancing forum, which is probably the better method to get your issue fixed a little quicker.

    It also might be a good idea to post up the code that you are having issues with - Please don't post up pages and pages of code, atleast try to narrow it down to a problematic chunk of code.
  11. Your post kinda hints towards you looking for a pre-made script you can just dump onto your site and everything works as you described. If so, this is not the forum for you, we are not here to write people scripts. If you are truly new to PHP I'd suggest you buy a book on the subject, read a few newbie tutorials or even read through the documentation over at php.net to get a feel for the language. For a project like you described, it'd be also helpful to know how to use MySQL databases too.
  12. [!--quoteo(post=362623:date=Apr 7 2006, 08:10 PM:name=darga333)--][div class=\'quotetop\']QUOTE(darga333 @ Apr 7 2006, 08:10 PM) [snapback]362623[/snapback][/div][div class=\'quotemain\'][!--quotec--]The only difference in the filenames is there is a tn_ before each file name when it is written to the uploads_thumbs/ folder. I was thinking that i can just add tn_ to your code images/tn_*.jpg, to get the identical file name?[/quote]Not exactly, the best thing to do to get the filenames to match here is to alter the substr() to knock of the tn_ along with the preceding directory name, so use $thumbs[] .= substr($t,17); instead of $thumbs[] .= substr($t,14);

    [!--quoteo(post=362623:date=Apr 7 2006, 08:10 PM:name=darga333)--][div class=\'quotetop\']QUOTE(darga333 @ Apr 7 2006, 08:10 PM) [snapback]362623[/snapback][/div][div class=\'quotemain\'][!--quotec--]also how do you make your reply look so nice and formatted with the different color around your code??[/quote]Use the [code ] and [/code ] tags.


    As for integrating it with your current script, I guess you could modify this a bit:
    [code] foreach ($new as $p) {
    createthumb($imagefolder.$p,$thumbsfolder."tn_".$p,100,100);
    echo "$p";
    }[/code]
    This will then loop through our newly created array containing only the required images, instead of the array of filenames built with your code here:
    [code]$pics=directory($imagefolder,"jpg,JPG,JPEG,jpeg,png,PNG");
    $pics=ditchtn($pics,"tn_");[/code]
  13. Glad you got it solved.

    For people that have found this thread because they are having a similar problem, this generally happens when you have the textarea tags on different lines, if you have put them all on the same line and the problem still persists, try running the defult content through trim() to strip white space from the begining and end of the string.
  14. Appologies, but I didn't actually read through all of your code - It looks like a lot of code for what you are trying to do, but anyway... Here is a possible solution for your problem with re-creating the same thumbnails each time the script is run, this will only work if both your original image and the thumbnail have the same name, but are stored in different directories, i.e. /images/ and /images/thumbs:

    [code]<?php
    //Set som variables up
    $orig = array();
    $thumbs = array();

    //Loop through images directory and put the file names only in an array
    foreach(glob("images/*.jpg") as $o) {
        $orig[] .= substr($o,7);
    }

    //Loop through images/thumbs directory and put the file names only in an array
    foreach(glob("images/thumbs/*.jpg") as $t) {
        $thumbs[] .= substr($t,14);
    }

    //Compare the two arrays, and return the filenames that appear in the original directory but not the thumbs directory
    $new = array_diff($orig,$thumbs);

    //We end up with the array $new containing all of the filenames for images that need thumbnails creating.
    ?>[/code]

    The above script is untested, it was made up as I went along, may need some tweaking if it doesn't work straight away... As for the script timing out, have you tried using set_time_limit(0) ?
  15. I'm looking for some good resources for learning how to manipulate images with JavaScript, not saving the changes - I want to create an interface where images can be resized, cropped and moved around a pre-defined space on the canvas - and then forward the coordinates and dimensions to a PHP script to finalise the changes...

    So, any good sites or books that cover this kinda stuff that you know of?
  16. [!--quoteo(post=361686:date=Apr 4 2006, 08:45 PM:name=Masna)--][div class=\'quotetop\']QUOTE(Masna @ Apr 4 2006, 08:45 PM) [snapback]361686[/snapback][/div][div class=\'quotemain\'][!--quotec--]2, just press Shift + 3, exactly like on a PC keyboard.[/quote]
    Maybe for your American keyboards, but on a British one, we have a pound (£) sign on our '3' key! And I did get it wrong, its alt+3 for a #, not option+3... On a UK keyboard that is anyway.
  17. Maybe try something like this?

    [code]<?php
    $query = "SELECT * FROM stores WHERE ";
    if(isset($city)) {
        $query .= "city LIKE '%$city%' AND ";
    }
    if(isset($state)) {
        $query .= "state LIKE '%$state%' AND ";
    }
    if(isset($type)) {
        $query .= "type LIKE '%$type%' AND ";
    }
    $query = substr($query,0,-5);

    mysql_query($query) or die(mysql_error());
    ?>[/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.