HoTDaWg Posted March 15, 2006 Share Posted March 15, 2006 hi,I have a script, which has an error. Php gives me the following error:[code]Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/cortez/public_html/testscripts/photoalbums/gallery.php on line 23[/code]I am trying to create a gallery of all the images which have been uploaded. Here is the script:[code]<html><head><title>Image Gallery</title><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"></head><body><?php$conn = mysql_connect("localhost","phpfreaks","rocks");//now choose the database to usemysql_select_db("cortez_photoalbums");$id = $_GET['id']; // retrieve id passed via URLif (isset($id)) { $query = "DELETE FROM images WHERE id = '$id' "; $result = mysql_query($query);}$getimages = mysql_query("SELECT * FROM images ORDER BY id DESC");while($r=mysql_fetch_array($getimages)) {extract($r); //remove the $r so its just $variable echo("<hr> Image: <image src='". $_POST['imageurl']"' height="50" width="50"><br> Id: $id <br> Date: $date<br> <a href='". $_SERVER['PHP_SELF']. "?id=". $id. "'>delete</a>"); }?></body></html>[/code]thanks,HotDawg Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 15, 2006 Share Posted March 15, 2006 well, it looks pretty good, except, it looks like you forgot to go back INTO the quotes. you also need to escape your double quotes within your string... try this on:[code]echo("<hr> Image: <image src='". $_POST['imageurl'] . "' height=\"50\" width=\"50\"><br> Id: $id <br> Date: $date<br> <a href='". $_SERVER['PHP_SELF']. "?id=$id'>delete</a>"); [/code]you simply forgot your second "."the other thought is to do this:[code]echo("<hr> Image: <image src='$_POST[imageurl]' height=\"50\" width=\"50\"><br> Id: $id <br> Date: $date<br> <a href='$_SERVER['PHP_SELF']?id=$id'>delete</a>"); [/code] Quote Link to comment Share on other sites More sharing options...
HoTDaWg Posted March 15, 2006 Author Share Posted March 15, 2006 the script seems a lot better now,we so far got:[code]<html><head><title>Homework Administration- Delete Homework</title><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"></head><body><?php$conn = mysql_connect("localhost","cortez","165745");//now choose the database to usemysql_select_db("cortez_photoalbums");$id = $_GET['id']; // retrieve id passed via URLif (isset($id)) { $query = "DELETE FROM images WHERE id = '$id' "; $result = mysql_query($query);}$getimages = mysql_query("SELECT * FROM images ORDER BY id DESC");while($r=mysql_fetch_array($getimages)) {extract($r); //remove the $r so its just $variable echo("<hr> Image: <image src='$_POST[imageurl]' height=\"50\" width=\"50\"><br> Id: $id <br> Date: $date<br> <a href='". $_SERVER['PHP_SELF']. "?id=$id'>delete</a>"); </body></html>[/code]the only problem is, as much, as i hate to say this i am getting the following error:[code]Parse error: syntax error, unexpected '<' in /home/cortez/public_html/testscripts/photoalbums/gallery.php on line 28[/code]strange.HotDawg Quote Link to comment Share on other sites More sharing options...
XenoPhage Posted March 15, 2006 Share Posted March 15, 2006 [!--quoteo(post=355481:date=Mar 15 2006, 04:19 PM:name=HoTDaWg)--][div class=\'quotetop\']QUOTE(HoTDaWg @ Mar 15 2006, 04:19 PM) [snapback]355481[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]<?php$conn = mysql_connect("localhost","cortez","165745");//now choose the database to usemysql_select_db("cortez_photoalbums");$id = $_GET['id']; // retrieve id passed via URLif (isset($id)) { $query = "DELETE FROM images WHERE id = '$id' "; $result = mysql_query($query);}$getimages = mysql_query("SELECT * FROM images ORDER BY id DESC");while($r=mysql_fetch_array($getimages)) {extract($r); //remove the $r so its just $variable echo("<hr> Image: <image src='$_POST[imageurl]' height=\"50\" width=\"50\"><br> Id: $id <br> Date: $date<br> <a href='". $_SERVER['PHP_SELF']. "?id=$id'>delete</a>"); </body></html>[/code][/quote]You didn't close out the php code.. You need to add ?> just before the </body> statement.. Quote Link to comment Share on other sites More sharing options...
HoTDaWg Posted March 15, 2006 Author Share Posted March 15, 2006 ooh whoops. Sorry guys. GOD GOD! HARD TO BELIEVE HOW MANY SYNTAX ERRORS I GOT! READ THIS:[code]Parse error: syntax error, unexpected $end in /home/cortez/public_html/testscripts/photoalbums/gallery.php on line 31[/code]here is the script we got so far:[code]<html><head><title>Homework Administration- Delete Homework</title><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"></head><body><?php$conn = mysql_connect("localhost","cortez","165745");//now choose the database to usemysql_select_db("cortez_photoalbums");$id = $_GET['id']; // retrieve id passed via URLif (isset($id)) { $query = "DELETE FROM images WHERE id = '$id' "; $result = mysql_query($query);}$getimages = mysql_query("SELECT * FROM images ORDER BY id DESC");while($r=mysql_fetch_array($getimages)) {extract($r); //remove the $r so its just $variable echo("<hr> Image: <image src='$_POST[imageurl]' height=\"50\" width=\"50\"><br> Id: $id <br> Date: $date<br> <a href='". $_SERVER['PHP_SELF']. "?id=$id'>delete</a>"); ?></body></html>[/code]this is really getting me angry (the script),HotDawg Quote Link to comment Share on other sites More sharing options...
XenoPhage Posted March 15, 2006 Share Posted March 15, 2006 [code]<html><head><title>Homework Administration- Delete Homework</title><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"></head><body><?php$conn = mysql_connect("localhost","cortez","165745");//now choose the database to usemysql_select_db("cortez_photoalbums");$id = $_GET['id']; // retrieve id passed via URLif (isset($id)) { $query = "DELETE FROM images WHERE id = '$id' "; $result = mysql_query($query);}$getimages = mysql_query("SELECT * FROM images ORDER BY id DESC");while($r=mysql_fetch_array($getimages)) {extract($r); //remove the $r so its just $variable echo("<hr> Image: <image src='$_POST[imageurl]' height=\"50\" width=\"50\"><br> Id: $id <br> Date: $date<br> <a href='". $_SERVER['PHP_SELF']. "?id=$id'>delete</a>");}?></body></html>[/code]You missed closing the while() loop.. Above passes a php lint test. Quote Link to comment Share on other sites More sharing options...
HoTDaWg Posted March 15, 2006 Author Share Posted March 15, 2006 i hate to be a pain guys, but the script is working! YAY! The only problem is that the images are not showing :(. I view sourced the page and here is what it showed:[code]<html><head><title>Homework Administration- Delete Homework</title><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"></head><body><hr> Image: <image src='' height="50" width="50"><br> Id: 14 <br> Date: 03.15.06<br> <a href='/testscripts/photoalbums/gallery.php?id=14'>delete</a><hr> Image: <image src='' height="50" width="50"><br> Id: 13 <br> Date: 03.15.06<br> <a href='/testscripts/photoalbums/gallery.php?id=13'>delete</a><hr> Image: <image src='' height="50" width="50"><br> Id: 12 <br> Date: 03.14.06<br> <a href='/testscripts/photoalbums/gallery.php?id=12'>delete</a><hr> Image: <image src='' height="50" width="50"><br> Id: 11 <br> Date: 03.14.06<br> <a href='/testscripts/photoalbums/gallery.php?id=11'>delete</a><hr> Image: <image src='' height="50" width="50"><br> Id: 10 <br> Date: 03.14.06<br> <a href='/testscripts/photoalbums/gallery.php?id=10'>delete</a><hr> Image: <image src='' height="50" width="50"><br> Id: 9 <br> Date: 03.14.06<br> <a href='/testscripts/photoalbums/gallery.php?id=9'>delete</a><hr> Image: <image src='' height="50" width="50"><br> Id: 8 <br> Date: 03.14.06<br> <a href='/testscripts/photoalbums/gallery.php?id=8'>delete</a><hr> Image: <image src='' height="50" width="50"><br> Id: 7 <br> Date: 03.13.06<br> <a href='/testscripts/photoalbums/gallery.php?id=7'>delete</a><hr> Image: <image src='' height="50" width="50"><br> Id: 6 <br> Date: 03.13.06<br> <a href='/testscripts/photoalbums/gallery.php?id=6'>delete</a></body></html>[/code]as you all may have noticed the image location does not come up for some reason.very weird,my appologies and thanks Quote Link to comment Share on other sites More sharing options...
HoTDaWg Posted March 16, 2006 Author Share Posted March 16, 2006 anyone? Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted March 16, 2006 Share Posted March 16, 2006 Why are you using $_POST['imageurl'] for the img src tag? Shouldn't that be some value from the database?[code]while($r=mysql_fetch_array($getimages)) {extract($r); //remove the $r so its just $variable echo("<hr> Image: <image src='$pathtofile' height=\"50\" width=\"50\"><br> Id: $id <br> Date: $date<br> <a href='". $_SERVER['PHP_SELF']. "?id=$id'>delete</a>");}[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.