Jump to content

PHP images not displaying


mdfcows

Recommended Posts

I had this page working fine where it retrieves a set of images from the database depending on what thumbnail was click on the previous page. Now I am trying to add an edit and delete button to each of the pictures and it will not display any of it now!

 

This is the code I am using:

<?php
	$id = $_GET[id];
	?>


	<?php
$max_items = 16; /* max number of news items to show */

require_once('config.php');
$db = mysql_connect (DB_HOST,DB_USER,DB_PASSWORD);
if(!$db) {
	die('Failed to connect to server: ' . mysql_error());
}
mysql_select_db (DB_DATABASE,$db);

function displayNews($all = 0) {
    global $db, $max_items;
    
    if ($all2 == 0) {
        /* query for news up to $max_items */
        $query13 = "SELECT image,id,description,projectcode,thumbnail " . 
                 
                 "FROM project WHERE projectcode='$id' ORDER BY id DESC LIMIT $max_items";
    } else {
        /* query for all news */
        $query13 = "SELECT image,id,description,projectcode,thumbnail " . 
                 
                 "FROM project WHERE projectcode='$id' ORDER BY id DESC";
    }
    $result13 = mysql_query($query13) or print("<p>Error fetching entries from the database, error: " .	"Statement: " .	$query13 . "</p>" . mysql_error());


    while ($row13 = mysql_fetch_array($result13)) {
        
        $title = htmlentities ($row13['description']);
        $news = nl2br (strip_tags ($row13['projectcode'], '<a><b><i><u>'));
	$image = $row13['image'];
	$thumbnail = $row13['thumbnail'];
	$id = $row13['id'];
        
        /* display the data */

        echo "<div class='portfolioproject'>";?>

        <div class='boxgrid captionfull'>
			<a id="<?php echo $id ?>" class="example_group" href="images/gallery/<?php echo $image ?>" title="<?php echo $title ?>" rel="gallery"><img alt="" src="images/gallery/<?php echo $thumbnail ?>" width="122px" height="122px"</a>	
                
          </a>} 
               
        <?php	

	//Check whether the session variable SESS_MEMBER_ID is present or not

	if(isset($_SESSION['SESS_MEMBER_ID']) || (!trim($_SESSION['SESS_MEMBER_ID']) == '')) {
		echo "<form class='editbtn' action='editportfolio.php' method='POST'>";
		echo "<input type='hidden' name='idf' value='$id' />";
		echo "<input src='images/editbtn.png' type='image' value='Edit' />";
		echo "</form>";
		echo "<form class='editbtn' action='deleteportfolio.php' method='POST'>";
		echo "<input type='hidden' name='ide' value='$id' />";
		echo "<input src='images/delbtn.png' type='image' value='Delete' />";
		echo "</form>";
	} else {
		echo "";
	}


	echo "</div>";

    }
    
    /* if not displaying all news, give a link to do so */
    if ($all == 0) {
        echo "<div class='show_all'><a class='show' href=\"{$_SERVER['PHP_SELF']}" .
             "?action=all\">Show all</a></div>\n";
    }
}

/* this is where the script decides what do do */

echo "\n";
switch($_GET['action']) {

    case 'all':
        displayNews(1);
        break;
    default:
        displayNews();
}
echo "\n";
?>

<?php
//Check whether the session variable SESS_MEMBER_ID is present or not
if(isset($_SESSION['SESS_MEMBER_ID']) || (!trim($_SESSION['SESS_MEMBER_ID']) == '')) {
echo "<span class='show_all'>";
echo "<a class='show' href='admincp.php'>  Admin</a>";
echo "</span>";
echo "<span class='show_all'>";
echo "<a class='show' href='logout.php'> Logout</a>";
echo "</span>";
} else {
echo "";
}
?>

 

No error messages are displayed, only the 'show all' button, and the 'admin' and 'logout' buttons if signed in!

 

Any help on this would be much appreciated!

 

Thank you

 

Martin

Link to comment
Share on other sites

I spy with my little eye...

Line 19: where does $all2 come from? It's not in your global statement, so it can't get it from outside the function, and it's not being set inside it either.

    if ($all2 == 0) {

Lines 46-48: an <img> tag that never ends, two ending tags for the <a>, and an ending brace that's out of place (I'm guessing you don't need it anyways).

				<a id="<?php echo $id ?>" class="example_group" href="images/gallery/<?php echo $image ?>" title="<?php echo $title ?>" rel="gallery"><img alt="" src="images/gallery/<?php echo $thumbnail ?>" width="122px" height="122px"</a>
                
          </a>} 

 

Link to comment
Share on other sites

Hey! Cheers for those mistakes I had in the code, I've changed all the ones you pointed out and she still isn't working!

 

The code now is this:

 

<?php
	$id = $_GET[id];
	?>


	<?php
$max_items = 16; /* max number of news items to show */

require_once('config.php');
$db = mysql_connect (DB_HOST,DB_USER,DB_PASSWORD);
if(!$db) {
	die('Failed to connect to server: ' . mysql_error());
}
mysql_select_db (DB_DATABASE,$db);

function displayNews($all = 0) {
    global $db, $max_items;
    
    if ($all == 0) {
        /* query for news up to $max_items */
        $query13 = "SELECT image,id,description,projectcode,thumbnail " . 
                 
                 "FROM project WHERE projectcode='$id' ORDER BY id DESC LIMIT $max_items";
    } else {
        /* query for all news */
        $query13 = "SELECT image,id,description,projectcode,thumbnail " . 
                 
                 "FROM project WHERE projectcode='$id' ORDER BY id DESC";
    }
    $result13 = mysql_query($query13) or print("<p>Error fetching entries from the database, error: " .	"Statement: " .	$query13 . "</p>" . mysql_error());


    while ($row13 = mysql_fetch_array($result13)) {
        
        $title = htmlentities ($row13['description']);
        $news = nl2br (strip_tags ($row13['projectcode'], '<a><b><i><u>'));
	$image = $row13['image'];
	$thumbnail = $row13['thumbnail'];
	$id = $row13['id'];
        
        /* display the data */

        echo "<div class='portfolioproject'>";?>
	<div class='boxgrid captionfull'>
            
            
			<a id="<?php echo $id ?>" class="example_group" href="images/gallery/<?php echo $image ?>" title="<?php echo $title ?>" rel="gallery"><img alt="" src="images/gallery/<?php echo $thumbnail ?>" width="122px" height="122px"/></a>	
                
               
        <?php	

	//Check whether the session variable SESS_MEMBER_ID is present or not

	if(isset($_SESSION['SESS_MEMBER_ID']) || (!trim($_SESSION['SESS_MEMBER_ID']) == '')) {
		echo "<form class='editbtn' action='editportfolio.php' method='POST'>";
		echo "<input type='hidden' name='idf' value='$id' />";
		echo "<input src='images/editbtn.png' type='image' value='Edit' />";
		echo "</form>";
		echo "<form class='editbtn' action='deleteportfolio.php' method='POST'>";
		echo "<input type='hidden' name='ide' value='$id' />";
		echo "<input src='images/delbtn.png' type='image' value='Delete' />";
		echo "</form>";
	} else {
		echo "";
	}


	echo "</div>";

    }
    
    /* if not displaying all news, give a link to do so */
    if ($all == 0) {
        echo "<div class='show_all'><a class='show' href=\"{$_SERVER['PHP_SELF']}" .
             "?action=all\">Show all</a></div>\n";
    }
}

/* this is where the script decides what do do */

echo "\n";
switch($_GET['action']) {

    case 'all':
        displayNews(1);
        break;
    default:
        displayNews();
}
echo "\n";
?>

<?php
//Check whether the session variable SESS_MEMBER_ID is present or not
if(isset($_SESSION['SESS_MEMBER_ID']) || (!trim($_SESSION['SESS_MEMBER_ID']) == '')) {
echo "<span class='show_all'>";
echo "<a class='show' href='admincp.php'>  Admin</a>";
echo "</span>";
echo "<span class='show_all'>";
echo "<a class='show' href='logout.php'> Logout</a>";
echo "</span>";
} else {
echo "";
}
?>

 

You or anyone else see what it could be?

Thanks for the help so far!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.