it's following best practice guidelines! :lol: :D good stuff!
Quote:
The var_dump lines were mostly for your educational benefit
Yes I understand this now, thanks.
Quote:
You have to run your MySQL code before you have anything in $row['title'] to display. Just put that code up top and then you'll be able to insert the gallery title into your browser's title bar with no problems.
Do you mean before <html> ?
PHP Code:
<?php
require_once('includes/mysql_connect.inc.php');
$sql = "SELECT title, DATE_FORMAT(gallery.date, '%M %D %Y') AS dr, caption
FROM photos
LEFT JOIN gallery
ON gallery.date = photos.date
WHERE photo_id = ".((int)$_GET['photo_id']);
$result = @mysql_query($sql) or die('Error: ' . mysql_error());
while ($row = mysql_fetch_array ($result)) {
echo '<h1>' . $row['title'] . '</h1><p>Date: ' . $row['dr'] . '</p><a href="javascript:history.go(-1)"><img src="images/170307/' . $row['photo_id'] . '.jpg" title="' . $row['caption'] . '"></a><h5>' . $row['caption'] . '</h5>';
}
?>
<html>
<head>
<title><?php echo $row['title'] ?></title>
..
but I want (below) in the <body> how do I break this up? Just open and close the php tags? do i just run up to while ($row = mysql_fetch_array ($result)) { before the <html> then echo my $rows where needed?:
<body>
<p>welcome</p>
PHP Code:
echo '<h1>' . $row['title'] . '</h1><p>Date: ' . $row['dr'] . '</p><a href="javascript:history.go(-1)"><img src="images/170307/' . $row['photo_id'] . '.jpg" title="' . $row['caption'] . '"></a><h5>' . $row['caption'] . '</h5>';
...
...
<h1>
PHP Code:
<?php echo $row['title'] ?>
</h1>
blar.. more html stuff
then example, another
<h1>
PHP Code:
<?php echo $row['something'] ?>
</h1>
</body>
?
Quote:
Notice in the SQL statement I added ((int)$_GET['photo_id']) - this is a basic method called type-casting that forces the value inserted into the string to be an integer.
yes am with you on that, I understand what you mean, thanks
Quote:
The reason you had to select photo_id is because you were using $row['photo_id'] in your output; I would recommend instead not selecting photo_id in the query and instead using $_GET['photo_id'] in your output - this will be more efficient (albeit not noticeably so) but more importantly follows best practice guidelines.
how would I put it into output? "not noticeably" where? If i don't select photo_id in the query I cant see the big image?
Quote:
I'd recommend a change to your .htaccess rule that will further protect your script: since your photo_id is always numeric (at least, I'm assuming..
yes right again :) thanks a lot