Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0

    Two identical pages don't work


    Hi,

    I wonder if anyone can give me any pointers to this problem, which is driving me nuts!

    I have a page which references a database to randomly pull images and links out of my database.

    I have made a duplicate of this database in the new website and when I run the same page with the new user information it doesn't work. I have added all permissions, checked the database, uploaded all sorts of version and it just refuses to work.

    My code is:
    PHP Code:
    <?php

        $user 
    "outposts_xxxxx";
        
    $pwd "xxxxxxxxx";
        
        require(
    "php/includes/dbConnect.php");
        
        
    //  Select Five Random Previous Jobs
        
    $query "SELECT * FROM work ORDER BY RAND() LIMIT 5";
        
    $pastwork mysql_query($query$connection) or die ("Could not excute MYSQL query");

    ?>

    And later in the page:

    <?

        
    while ($row mysql_fetch_array($pastwork)) {
        
        
    $id $row['id'];
        
    $image_url $row['image_url'];
        
    $link_url $row['link_url'];
        
    $alt_text $row['alt_text'];
        
    $rel $row['rel'];
        
    $type $row['type'];
        
    $desc $row['desc'];
        
    $short_desc $row['short_desc'];
        
        echo 
    $image_url;
        echo 
    $id;
        echo 
    $link_url;
        echo 
    $alt_text;
        
        echo
    "<a href=\"".$link_url."\" id=\"mb".$id."\" rel=\"".$rel."\" class=\"mb\" title=\"".$type."\">
                <img src=\""
    .$image_url."\" alt=\"".$alt_text."\" border=\"1\" class=\"mainImages\"></a>
                <div class=\"multiBoxDescription mb"
    .$id."\">".$desc."</div>
                <span class=\"maintextNoPad9px\">"
    .$short_desc."</span><br>
                <br>"
    ;
        
        }
        
    ?>
    All I get is the page with the following:

    A broken link to the image and:

    ".$desc."
    ".$short_desc."

    "; } ?>

    Any help would be gratefully received.

    Thanks....
    Last edited by drgroove; January 27th, 2014 at 12:52 PM. Reason: Added php tags.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,602
    Rep Power
    595
    1) Please use [ PHP ] tags for your code. See the sticky at the top of this forum that says READ THIS BEFORE POSTING.
    2) Start by comparing phpinfo() on both servers. Obviously there is something different that is not immediatly obvious.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Sep 2006
    Posts
    2,042
    Rep Power
    535
    Start simple.

    What do you get running this script on both servers?

    PHP Code:
    <?php
    echo('Hello world');
    ?>
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0
    They are on the same server. It is a virtual via blue host. If I run phpinfo() I get the same on both sites.

    I thought it was a DB connection issue but have put breakpoints in the code and it connects ok. The user has all privileges for testing purposes and that doesn't work. Even tried really specifically identifying the DB and table for the query and no difference.
  8. #5
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    you're using a short PHP tag:

    Code:
    <?
    Your server (or this particular virtual host) obviously doesn't support it. That's why the PHP code gets output literally rather than evaluated.

    Also note that your code is insecure and heavily outdated. It might be a good idea to rewrite it and make it fit for the 21st century.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0
    Hi. No. It doesn't make any difference. I used <php before.
  12. #7
  13. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    There is no "<php" tag. You need "<?php".

    Yes, this is an issue with the tags. As you can see in the output, the PHP code doesn't even get evaluated. That means there's a problem with how you embed the PHP code into the HTML markup. It's not a problem of the code itself.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0
    Originally Posted by Jacques1
    There is no "<php" tag. You need "<?php".

    Yes, this is an issue with the tags. As you can see in the output, the PHP code doesn't even get evaluated. That means there's a problem with how you embed the PHP code into the HTML markup. It's not a problem of the code itself.
    Hi, yes. I appreciate that. I have changed the code to <?php sorry that was a typo. It still doesn't work.

    I have run the "Hello World" script and that does....

    It is just so weird that it works on the other site, on the same server with the same php.ini file....
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0
    Out of interest, when I have now made a short script to attach to the database and then run my query I get 'Could not execute MySQL query'. I know it's connecting because I don't get an error and can see the state of $connection.

    Here's the code:

    $connection = mysql_connect("localhost", $user, $pwd) or die ("Could not connect to database server");

    print $connection;

    $query = "SELECT * FROM work ORDER BY RAND() LIMIT 5";
    $pastwork = mysql_query($query, $connection) or die ("Could not excute MYSQL query");
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,602
    Rep Power
    595
    Start by following Jacques1's advice. Get rid of the ancient, deprecated MySQL extensions. Switch to PDO then see where you stand.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0
    Originally Posted by gw1500se
    Start by following Jacques1's advice. Get rid of the ancient, deprecated MySQL extensions. Switch to PDO then see where you stand.
    With all due respect that is pointless. It WORKS on the same server on another site running the same code with the same version of PHP.
  22. #12
  23. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Sh*tting in one's pants also "works". That doesn't make it a valid alternative to going to the toilet.

    Comments on this post

    • badger_fruit agrees : I think I might write a new website purely in mysql_* and post the code here just to see what Jacques1 comes out with. That's frickin golden lol!!!!
    • gw1500se agrees : :D What can one possible say to top that?
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    721
    Rep Power
    7
    I see you connecting to a MySQL server and all, but are you selecting a database at all?
    He who knows not and knows not he knows not: he is a fool - shun him. He who knows not and knows he knows not: he is simple - teach him. He who knows and knows not he knows: he is asleep - wake him. He who knows and knows he knows: he is wise - follow him
  26. #14
  27. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,184
    Rep Power
    492
    okay so triple nothing; the OP said he's tried that to no avail but my question is regarding the server setup. Is the DB local or remote to the "new" website (likewise, is it local/remote to the old one)?

    I don't fully understand the setup, please explain the configuration in more detail, that might be the key here.
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0
    I don't fully understand the setup, please explain the configuration in more detail, that might be the key here.[/QUOTE]

    OK, so what I did was export the original database and then import it into the new site. I can run queries on it from MySQL Admin no problem. The database is identical. I have given the user all privileges and it still doesn't work.

    I have also set the database to outposts.robs.work and that doesn't work. I have also used a direct connection to the box instead of relying on localhost with no joy.

    Thanks all. I appreciate your help.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo