Having problems with inherited code...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kirkk
Forum Newbie
Posts: 2
Joined: Thu Jun 25, 2009 9:56 am

Having problems with inherited code...

Post by kirkk »

I'm working on a project started by someone else and having problems with their code not working. Basically it's supposed to be getting the page name and then looking up a record in MySQL to pull content to be used on the webpage. It's not pulling any of the information referenced in the page... description, title, id, content. I've pasted the relevant code below and any help you can provide would be greatly appreciated.

Cheers!
Kirk

Code: Select all

 
<?php include("includes/MySQL_Functions.php"); include("includes/page_functions.php");
    $mysql = new MySQL_Functions();
    $mysql->connect();
    $page = $mysql->query("SELECT * FROM pages WHERE url='".mysql_real_escape_string($_SERVER['PHP_SELF'])."' LIMIT 1", "single");
    if($page==""){
            $mysql->insert("INSERT INTO pages(url, title, description, content) VALUES('".mysql_real_escape_string($_SERVER['PHP_SELF'])."', '".mysql_real_escape_string(basename($_SERVER['SCRIPT_NAME']))."', ' ', 'Lorem ipsum dolor sit amet.')");
            $page = $mysql->query("SELECT * FROM pages WHERE id='".$mysql->get_last_id()."' LIMIT 1", "single");
        if(isset($_COOKIE['admin'])){
        }else{
            $mysql->close();
            redirect("./");
        }
    }
    //$galleries = $mysql->query("SELECT gallery.id, gallery.name FROM gallery, page_gallery WHERE gallery.id=page_gallery.gallery_id AND page_gallery.page_id='".$page["id"]."'");
    $mysql->close();
    
?>
 
<meta name="description" content="<?=$page["description"]?>" />
<title><?=$page["title"]?></title>
<?php if(isset($_COOKIE['admin'])){?><a href="edit_page.php?edit-field=<?=$page["id"]?>" rel="lyteframe[EditPage]" title="Page Editor" rev="width: 800px; height: 600px; scrolling: no;">Edit Page</a><br /><br /><?php }?>
<?=$page["content"]?>
 
divito
Forum Commoner
Posts: 89
Joined: Sun Feb 22, 2009 7:29 am

Re: Having problems with inherited code...

Post by divito »

Any error messages?
kirkk
Forum Newbie
Posts: 2
Joined: Thu Jun 25, 2009 9:56 am

Re: Having problems with inherited code...

Post by kirkk »

divito wrote:Any error messages?
Thanks for the reply. Not getting any error messages but a couple of things I'm seeing...

The page title (which should be 'index.php') is just displaying the php code... <?=$page["title"]?>

Also... at the very top-left corner of the page it shows " /> which is the very end of the line...

<meta name="description" content="<?=$page["description"]?>" />

Also... this is running on a Windows 2003 Server under IIS using PHP 5.2.9 and MySQL 5.1.35.

Hope this helps. Thanks again!

Kirk
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Having problems with inherited code...

Post by Darhazer »

short_tags are disabled on your server, that's why the page title is not displayed correctly. Enable them in your php.ini
Post Reply