Here is my code... index.php <?php include('config.php'); echo"<div class='imageRow'> <div class='set'>"; $query="select * FROM photos"; $result = mysql_query("SELECT * FROM photos ORDER BY id DESC;"); while($row = mysql_fetch_array($result)) { echo '<div class="single"><div class="wrap"> <div class="details"> <div class="views"> <a href="viewingimg.php?id=" '.$row['image'].'" title="'.$row['caption'].'"><img src="'.$row['image'].'" /></a>' . $row['details'] . ' </div></div></div></div>'; } ?> Code (markup): imgview.php <?php include('config.php'); $id = $_GET['id']; if(!isset($id) || empty($id) || !is_int($id)){ die("Please select your image!"); }else{ $query = mysql_query("SELECT * FROM photos WHERE id='".$id."'"); $row = mysql_fetch_array($query); $content = $row['image']; header('Content-type: image/jpg'); echo $content; } ?> Code (markup): But when i click on the image is gives error PLEASE SELECT YOUR IMAGE....can anyone help me where i m wrong .. Thanks
while($row = mysql_fetch_array($result)) { [COLOR=#ff0000] //[/COLOR]echo '<div class="single"><div class="wrap"> <div class="details"> <div class="views"> <a href="viewingimg.php?id=" '.$row['image'].'" title="'.$row['caption'].'"><img src="'.$row['image'].'" /></a>' . $row['details'] . ' [COLOR=#ff0000] echo 'id="'.$row['image'].'"';[/COLOR] Code (markup): Then you'll see what data you're sending to imageview.php You seem to be sending the file name as the id. Maybe you meant $row['id']?
<?php include('config.php'); echo"<div class='imageRow'> <div class='set'>"; $query="select * FROM photos"; $result = mysql_query("SELECT * FROM photos ORDER BY id DESC;"); while($row = mysql_fetch_array($result)) { echo '<div class="single"><div class="wrap"> <div class="details"> <div class="views"> <a href="viewingimg.php?id=" '.$row['image'].'" title="'.$row['caption'].'"><img src="'.$row['image'].'" /></a>' . $row['details'] . ' echo 'id="'.$row['image'].'"'; </div></div></div></div>'; } ?> Code (markup): Error Parse error: syntax error, unexpected 'id' (T_STRING), expecting ',' or ';' in C:\xampp\htdocs\test\index.php on line 44
This script is realy weird, te script referers to viewingimg.php but you show code for imgview.php ? does the script exists? try to open the 'not visable' image into a new screen and then check the URL!
. my page is saved as viewingimg.php ... in this forum i just mentioned imgview by mistake, sorry for that, i m just a newbie, trying to learn and do something with php, just need help
<?php include('config.php'); echo"<div class='imageRow'> <div class='set'>"; $query="select * FROM photos"; $result = mysql_query("SELECT * FROM photos ORDER BY id DESC;"); while($row = mysql_fetch_array($result)) { echo '<div class="single"><div class="wrap"> <div class="details"> <div class="views"> <a href="viewingimg.php?id=" '.$row['image'].'" title="'.$row['caption'].'"><img src="'.$row['image'].'" /></a>' . $row['details'] . ' echo 'id="'.$row['image'].'"'; [COLOR=#ff0000]echo '[/COLOR]</div></div></div></div>'; } ?> Code (markup): I left off the bottom of the code. Sorry.
the problem come from this code <a href="viewingimg.php?id=" '.$row['image'].'" title="'.$row['caption'].'"><img src="'.$row['image'].'" /></a>' PHP: this code will produce html like this <a href="viewingimg.php?id=" filename.ext" title="any title"><img src="filename.ext" /></a> HTML: you can check its html source from your browser. this is a wrong link tags, so query id always empty. try to remove quote and space behind id= like this <a href="viewingimg.php?id='.$row['image'].'" title="'.$row['caption'].'"><img src="'.$row['image'].'" /></a>' PHP:
thanks for ur replies, but it still doesn't work, problem is here viewingimg.php <?php include('config.php'); $id = $_GET['id']; if(!isset($id) || empty($id) || !is_int($id)){ die("Please select your image!"); }else{ $query = mysql_query("SELECT * FROM photos WHERE id='".$id."'"); $row = mysql_fetch_array($query); $content = $row['image']; header('Content-type: image/jpg'); echo $content; } ?> Code (markup): Error Msg Notice: Undefined index: id in C:\xampp\htdocs\test\viewingimg.php on line 37 Please select your image! Line 37 = $id = $_GET['id'];
That's because there's no element in the form on the page with a name of id. The GET variables come from the HTML form, they're the names of the elements (textboxes, etc.) in the form. You have to have a textbox or dropdown or something named id (as in name="id"). In your case it will probably be an array of checkboxes named id. Or an array of checkboxes with different names, and your PHP code sees which one is checked and makes $id the name of that checkbox (or whatever calue you need it to be to find the picture in the database).
@Alibaba143 problem come from your index.php not in your viewingimg.php please edit first your index.php like i said. @Rukbat he have, look at his index.php he have query id with wrong link tag. so he always get url http://localhost/test/viewingimg.php?id= the url always ended with id= without query value so $_GET['id'] always have empty value. it must http://localhost/test/viewingimg.php?id=file.jpg like you type url http://www.google.com/search?q= what you'll get with url like that?
I have done the same u said, but it gives syntax error Parse error: syntax error, unexpected 'id' (T_STRING), expecting ',' or ';' in C:\xampp\htdocs\test\index.php on line45 Line 45 = echo 'id="'.$row['image'].'"';
I can't be sure without seeing more code, but make sure line 44 ends with a ; And make sure that's line 45. There doesn't seem to be anything wrong with it.
here is the whole code <?php include('config.php'); echo"<div class='imageRow'> <div class='set'>"; $query="select * FROM photos"; $result = mysql_query("SELECT * FROM photos ORDER BY id DESC;"); while($row = mysql_fetch_array($result)) { echo '<div class="single"><div class="wrap"> <div class="details"> <div class="views"> <a href="viewingimg.php?id=" '.$row['image'].'" title="'.$row['caption'].'"><img src="'.$row['image'].'" /></a>' . $row['details'] . ' echo 'id="'.$row['image'].'"'; echo '</div></div></div></div>'; } ?> Code (markup): error is Parse error: syntax error, unexpected 'id' (T_STRING), expecting ',' or ';' in C:\xampp\htdocs\test\index.php on line45 Line 45 = echo 'id="'.$row['image'].'"';
Free help <?php include('config.php'); echo"<div class='imageRow'> <div class='set'>"; $query="select * FROM photos"; $result = mysql_query("SELECT * FROM photos ORDER BY id DESC;"); while($row = mysql_fetch_array($result)) { echo '<div class="single"><div class="wrap"> <div class="details"> <div class="views"> <a href="viewingimg.php?id=" '.$row['image'].'" title="'.$row['caption'].'"><img src="'.$row['image'].'" /></a>' . $row['details']; echo 'id="'.$row['image'].'"'; echo '</div></div></div></div>'; } ?> Code (markup): that should work...
Thanks EricBruggema but now it shows id with the pic details, like pic name is funny, it shows like ... funnyid="photos/funny... and the url is ... localhost/test/viewingimg.php?id= its not getting pic id and displaying the pic
<?php include('config.php'); echo"<div class='imageRow'> <div class='set'>"; $query="select * FROM photos"; $result = mysql_query("SELECT * FROM photos ORDER BY id DESC;"); while($row = mysql_fetch_array($result)) { echo '<div class="single"><div class="wrap"> <div class="details"> <div class="views"> <a href="viewingimg.php?id='.$row['image'].'" title="'.$row['caption'].'"><img src="'.$row['image'].'" /></a>' . $row['details'] . ' </div></div></div></div>'; } ?> PHP:
Thanks ogah, i read ur post...but it doesn't show pic...when i click on the image, it gives the link like http://localhost/test/viewingimg.php?id=file.jpg but not showing pic. it give the msg Please Select Your Image.
your index.php showing the image or not? if your index.php showing image, try edit viewingimg.php remove || !is_int($id)