Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Junior Member Drattis's Avatar
    Join Date
    Nov 2012
    Posts
    23
    Member #
    33947
    Liked
    1 times
    My website is a site with funny pictures. There is one picture on each page. I want the newest uploaded page to have a title saying: Funny Pictures for everybody - Drattis.com. And I want the other uploaded pages title to say something about the image that has been uploaded, for example: Funny cat riding a bike.

    So this is the code I have at the moment:

    <title>
    <?php
    include 'get.php';
    include 'upload.php';
    if($id === $lastid){
    echo "Funny Pictures for everybody - Drattis.com";
    }else{
    echo $_POST[title];
    }
    ?>
    </title>

    Will this work? id is the current id of the page and lastid is the latest uploaded page's id. title is the short sentance saying something about the image, as in the example above: Funny cat riding a bike.

  2.  

  3. #2
    Senior Member hagen's Avatar
    Join Date
    Aug 2005
    Posts
    408
    Member #
    10882
    Liked
    1 times
    no (not entirely sure what you are trying to do)...

    BUT the $_POST['title'] will only exist for the client who has posted the data... NB single quotes...

    you will probably have to the picture information out of the database table with some sql code... IE

    SELECT title FROM table WHERE id='$id'
    Drattis likes this.
    Hagen Rose: hagen(at)jxwd(dot)co(dot)uk
    JX Web Development, Bournemouth, Dorset...JXWD.co.uk

  4. #3
    Junior Member Drattis's Avatar
    Join Date
    Nov 2012
    Posts
    23
    Member #
    33947
    Liked
    1 times
    nevermind what i wrote above, i have changed everything so this is what it looks like right now, but i get no result, i should get an appropriate title but i only get the filename as a title (link: www.drattis.com/49.php).

    Code:

    <?php
    include 'core/init.php';
    include 'includes/overall/headerover.php';
    ?>

    <?php
    include 'get.php';
    include 'upload.php';
    echo "<title>" . $_GET['title'] . "</title>";
    ?>
    <?php
    include 'includes/overall/headerunder.php';
    ?>

    Why isn't it working?

  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,716
    Member #
    5580
    Liked
    718 times
    A blank white page is usually a php script failure and you have error reporting turned off.

    google: php error reporting
    Drattis likes this.


  6. #5
    Junior Member Drattis's Avatar
    Join Date
    Nov 2012
    Posts
    23
    Member #
    33947
    Liked
    1 times
    Hmm, i'm not getting a blank page, I'm getting a gray page, this is because the only thing that gets included is headerover.php and this consists of the code bellow (with the css link thing where it says to make the page gray:

    <!DOCTYPE html>
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="css/style.css" />

    The other includes are not being included and i wonder why, I turned on error reporting and i got this message: Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /customers/b/c/6/drattis.com/httpd.www/get.php on line 2 Warning: mysql_connect(): [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known (trying to connect via tcp://drattis_com:3306) in /customers/b/c/6/drattis.com/httpd.www/get.php on line 2 Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /customers/b/c/6/drattis.com/httpd.www/get.php on line 2

  7. #6
    Junior Member Drattis's Avatar
    Join Date
    Nov 2012
    Posts
    23
    Member #
    33947
    Liked
    1 times
    this is get.php code:

    <?php
    mysql_connect("drattis_com", "drattis_com", "---I removed this i think its the password---") or die(mysql_error());
    mysql_select_db("drattis_com") or die(mysql_error());

    $id = addslashes($_REQUEST['id']);

    $image = mysql_query("SELECT * FROM store WHERE id = $id");
    $image = mysql_fetch_assoc($image);
    $image = $image['image'];

    header("Content-type: image/jpeg");
    ?>

  8. #7
    Junior Member Drattis's Avatar
    Join Date
    Nov 2012
    Posts
    23
    Member #
    33947
    Liked
    1 times
    Okay I fixed the above code in get.php (I had the wrong information in mysql_connect on the first second line.)

    But... now I'm getting other errors (bellow):

    Notice: Undefined index: id in /customers/b/c/6/drattis.com/httpd.www/get.php on line 5 Notice: A session had already been started - ignoring session_start() in /customers/b/c/6/drattis.com/httpd.www/core/init.php on line 2 Fatal error: Cannot redeclare copy_directory() in /customers/b/c/6/drattis.com/httpd.www/core/functions/general.php on line 2

    The get.php code which the errors are referring to is bellow:

    <?php
    mysql_connect("drattis.com.mysql", "drattis_com", "---I removed this i think its the password---") or die(mysql_error());
    mysql_select_db("drattis_com") or die(mysql_error());

    $id = addslashes($_REQUEST['id']);

    $image = mysql_query("SELECT * FROM store WHERE id = $id");
    $image = mysql_fetch_assoc($image);
    $image = $image['image'];

    header("Content-type: image/jpeg");
    ?>

  9. #8
    Junior Member Drattis's Avatar
    Join Date
    Nov 2012
    Posts
    23
    Member #
    33947
    Liked
    1 times
    init.php:

    <?php
    session_start();
    require 'database/connect.php';
    require 'functions/general.php';
    require 'functions/users.php';

    if(logged_in() === true) {
    $session_user_id = $_SESSION['user_id'];
    $user_data = user_data($session_user_id, 'user_id', 'username', 'password', 'first_name', 'last_name', 'email');
    if(user_active($user_data['username']) === false) {
    session_destroy();
    header('Location: admin.php');
    exit();
    }
    }

    $errors = array();
    ?>

    general.php:

    <?php
    function copy_directory( $source, $destination ) {
    if ( is_dir( $source ) ) {
    @mkdir( $destination );
    $directory = dir( $source );
    while ( FALSE !== ( $readdirectory = $directory->read() ) ) {
    if ( $readdirectory == '.' || $readdirectory == '..' ) {
    continue;
    }
    $PathDir = $source . '/' . $readdirectory;
    if ( is_dir( $PathDir ) ) {
    copy_directory( $PathDir, $destination . '/' . $readdirectory );
    continue;
    }
    copy( $PathDir, $destination . '/' . $readdirectory );
    }

    $directory->close();
    }else {
    copy( $source, $destination );
    }
    }

    ?>

  10. #9
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,716
    Member #
    5580
    Liked
    718 times
    Drattis ...
    You have created a separate .html page for each photo?
    Is there a reason you are not using one PHP script to display the photos?


  11. #10
    Junior Member Drattis's Avatar
    Join Date
    Nov 2012
    Posts
    23
    Member #
    33947
    Liked
    1 times
    yes i do have different html pages for each image, i have no idea what im doing with my php code, i am just trying to implement it in my site and at the same time learn it so i have to be sincere and tell you that i have no idea how to make it with a php script.

    Since i wrote this thread i solved ALL errors except thees ones:

    Notice: Undefined index: id in /customers/b/c/6/drattis.com/httpd.www/get.php on line 5

    Notice: Undefined index: title in /customers/b/c/6/drattis.com/httpd.www/79.php on line 8


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 02:30 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com