Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jan 2009
    Posts
    204
    Thanks
    29
    Thanked 0 Times in 0 Posts

    output variables

    How do I get the output variables to HERE

    Code:
    <?php
    // connect to your MySQL database here
    
    $db_hostname = 'localhost';
    $db_database = 'kellys_backgrounds';
    $db_image = 'root';
    $db_password = '';
    
    // Connect to server.
    $db_server = mysql_connect($db_hostname, $db_image, $db_password)
        or die("Unable to connect to MySQL: " . mysql_error());
    
    // Select the database.
    mysql_select_db($db_database)
        or die("Unable to select database: " . mysql_error());
    
    // Build the sql command string
    $sqlCommand = "SELECT image, continant, country FROM wallpapers ORDER BY RAND() LIMIT 1";
    // Execute the query here now
    $query = mysql_query($sqlCommand) or die (mysql_error());
    // Output the data here using a while loop, the loop will return all members
    while ($row = mysql_fetch_array($query)) {
        // Gather all $row values into local variables for easier usage in output
        $continant = $row["continant"];
        $country = $row["country"];
        $image = $row["image"];
    
        // echo the output to browser or compound an output variables here
        echo "$continant/$country/$image
    
        ";
    }
    
    copy('H:/www/1TestingArea/1-New-Kellys-Stuff/test-pull/HERE', 'H:/www/1TestingArea/1-New-Kellys-Stuff/test-pull/Back-1/HERE');
    
    
    // close mysql connection
    mysql_close();
    ?>
    Last edited by Feckie; 06-11-2014 at 08:29 PM.

  • #2
    Regular Coder Linux_Sage's Avatar
    Join Date
    Mar 2014
    Location
    Sterling,VA
    Posts
    106
    Thanks
    0
    Thanked 10 Times in 10 Posts
    Can you be a bit more specific in what you're trying to accomplish?

  • #3
    Regular Coder
    Join Date
    Jan 2009
    Posts
    204
    Thanks
    29
    Thanked 0 Times in 0 Posts
    The echo "$continant/$country/$image gives me a random link which I then want to copy the image into a second folder

  • #4
    New Coder The Noob Coder's Avatar
    Join Date
    Jul 2012
    Location
    The City that Never Sleeps
    Posts
    99
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Feckie View Post
    The echo "$continant/$country/$image gives me a random link which I then want to copy the image into a second folder
    If your line

    PHP Code:
    echo "$continant/$country/$image"
    is supposed to print out a path to your image file, and you want to copy that image file to another directory, try the following:

    PHP Code:
    while ($row mysql_fetch_array($query)) {
        
    // Gather all $row values into local variables for easier usage in output
        
    $continant $row["continant"];
        
    $country $row["country"];
        
    $image $row["image"];

        
    $path $continant."/".$country."/".$image;
        echo 
    $path."\n";

        
    copy('H:/www/1TestingArea/1-New-Kellys-Stuff/test-pull/'.$path
                
    'H:/www/1TestingArea/1-New-Kellys-Stuff/test-pull/Back-1/'.$path);


    Notice how I put the copy operation in the while loop. This way, for every image, you'll copy it from its location indicated by the database table to this new location. Make sure to check the return value of the copy() function and take appropriate action if the copy() operation fails.
    PHP: copy - Manual

  • #5
    Regular Coder
    Join Date
    Jan 2009
    Posts
    204
    Thanks
    29
    Thanked 0 Times in 0 Posts
    Thanks it works as

    PHP Code:
      copy('H:/www/1TestingArea/1-New-Kellys-Stuff/test-pull/'.$path.''
    Last edited by Feckie; 06-11-2014 at 08:20 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •