Jump to content

Archived

This topic is now archived and is closed to further replies.

HoTDaWg

Variable and images

Recommended Posts

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 use
mysql_select_db("cortez_photoalbums");

$id = $_GET['id']; // retrieve id passed via URL
if (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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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 use
mysql_select_db("cortez_photoalbums");

$id = $_GET['id']; // retrieve id passed via URL
if (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

Share this post


Link to post
Share on other sites
[!--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 use
mysql_select_db("cortez_photoalbums");

$id = $_GET['id']; // retrieve id passed via URL
if (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..

Share this post


Link to post
Share on other sites
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 use
mysql_select_db("cortez_photoalbums");

$id = $_GET['id']; // retrieve id passed via URL
if (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

Share this post


Link to post
Share on other sites
[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 use
mysql_select_db("cortez_photoalbums");

$id = $_GET['id']; // retrieve id passed via URL
if (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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

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.