Jump to content


Photo

help with picture stuff


  • Please log in to reply
11 replies to this topic

#1 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 28 May 2006 - 06:51 AM

ok... heres the script that uploads(pictures show up in folder and open fine)
<?PHP
session_start();
$errors = array();
$user=$_SESSION['user'];

echo "<a href=home.php>Return Home</a>";
if(empty($_POST['ti'])){
        $errors[] = '<p><font color=\"yellow\">*Please enter a Title!</font></p>';
        }else{
        $ti=$_POST['ti'];
        }
        if(empty($_POST['pr'])){
        $errors[] = '<p><font color=\"yellow\">*Please enter a Price!</font></p>';
        }else{
        $pr=$_POST['pr'];
        }
        
        if(empty($_POST['de'])){
        $errors[] = '<p><font color=\"yellow\">*Please enter a Description!</font></p>';
        }else{
        $de=$_POST['de'];
        }
        if(move_uploaded_file($_FILES['ph']['tmp_name'], 
        "listingphoto/{$_FILES['ph']['name']}")) {
        }else{
         $errors[] = '<p><font color=\"yellow\">*Sorry There was a Problem Uploading Your Picture, Please Try again!</font></p>';
        }
if(isset($_POST['submit'])){
if (empty($errors)) {
$username="********";
$password="*********";
$database="*********";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
 echo "<br><br>Your Listing Was successfully Posted!";
$query2="INSERT INTO listings VALUES('','$ti','$pr','$de','{$_FILES['ph']['name']}','$user')";
$result2 = mysql_query($query2) or die ("Error in query: $query2. ".mysql_error());
    }else{
foreach ($errors as $key){
echo "$key";
}
}
    }
    echo "<form enctype=multipart/form-data method=post>
    <p>Title:<input type=text name=ti size=20></p>
    <p>Price:<input type=text name=pr size=12></p>
    <p>Photo:<input type=file name=ph size=20></p>
    <p>Description:<br>
    <textarea rows=5 name=de cols=23></textarea></p>
    <p><input type=submit value=Submit name=submit></p>
</form>";
?>

and heres the page that should view them but the pics show up as x's!!
<?PHP
session_start();

$id=$_GET['id'];
$user=$_SESSION['user'];
$username="*******";
$password="*******";
$database="********";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query2="SELECT * FROM listings WHERE id='$id'";

$result2 = mysql_query($query2) or die ("Error in query: $query2. ".mysql_error());
$num = mysql_num_rows ($result2);

echo "<p align=center>Welcome $user! <font size=2>Not you? <a href=login.php>Sign in!</a></font><br><a href=home.php>Return Home</a><br><br>";
while($row = mysql_fetch_row($result2)){
echo "<title>$row[1]</title>";

echo "<font size=4>$row[1]</font><br><br><b>Listed By:</b> $row[5]<br><Br><b>Price:</b> $$row[2]<br><br><b>Description:</b><br>$row[3]<br><br><img border=0 src=listingphoto/$row[4] width=281 height=283>";
}
?>

"Syntax error" .. WHERE THE **** IS IT?!

#2 wild_dog

wild_dog
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 28 May 2006 - 09:18 AM

[!--quoteo(post=377768:date=May 28 2006, 01:51 AM:name=legohead6)--][div class=\'quotetop\']QUOTE(legohead6 @ May 28 2006, 01:51 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
ok... heres the script that uploads(pictures show up in folder and open fine)
<?PHP
session_start();
$errors = array();
$user=$_SESSION['user'];

echo "<a href=home.php>Return Home</a>";
if(empty($_POST['ti'])){
        $errors[] = '<p><font color=\"yellow\">*Please enter a Title!</font></p>';
        }else{
        $ti=$_POST['ti'];
        }
        if(empty($_POST['pr'])){
        $errors[] = '<p><font color=\"yellow\">*Please enter a Price!</font></p>';
        }else{
        $pr=$_POST['pr'];
        }
        
        if(empty($_POST['de'])){
        $errors[] = '<p><font color=\"yellow\">*Please enter a Description!</font></p>';
        }else{
        $de=$_POST['de'];
        }
        if(move_uploaded_file($_FILES['ph']['tmp_name'], 
        "listingphoto/{$_FILES['ph']['name']}")) {
        }else{
         $errors[] = '<p><font color=\"yellow\">*Sorry There was a Problem Uploading Your Picture, Please Try again!</font></p>';
        }
if(isset($_POST['submit'])){
if (empty($errors)) {
$username="********";
$password="*********";
$database="*********";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
 echo "<br><br>Your Listing Was successfully Posted!";
$query2="INSERT INTO listings VALUES('','$ti','$pr','$de','{$_FILES['ph']['name']}','$user')";
$result2 = mysql_query($query2) or die ("Error in query: $query2. ".mysql_error());
    }else{
foreach ($errors as $key){
echo "$key";
}
}
    }
    echo "<form enctype=multipart/form-data method=post>
    <p>Title:<input type=text name=ti size=20></p>
    <p>Price:<input type=text name=pr size=12></p>
    <p>Photo:<input type=file name=ph size=20></p>
    <p>Description:<br>
    <textarea rows=5 name=de cols=23></textarea></p>
    <p><input type=submit value=Submit name=submit></p>
</form>";
?>

and heres the page that should view them but the pics show up as x's!!
<?PHP
session_start();

$id=$_GET['id'];
$user=$_SESSION['user'];
$username="*******";
$password="*******";
$database="********";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query2="SELECT * FROM listings WHERE id='$id'";

$result2 = mysql_query($query2) or die ("Error in query: $query2. ".mysql_error());
$num = mysql_num_rows ($result2);

echo "<p align=center>Welcome $user! <font size=2>Not you? <a href=login.php>Sign in!</a></font><br><a href=home.php>Return Home</a><br><br>";
while($row = mysql_fetch_row($result2)){
echo "<title>$row[1]</title>";

echo "<font size=4>$row[1]</font><br><br><b>Listed By:</b> $row[5]<br><Br><b>Price:</b> $$row[2]<br><br><b>Description:</b><br>$row[3]<br><br><img border=0 src=listingphoto/$row[4] width=281 height=283>";
}
?>
[/quote]


Where is the html that reads the location of the pictures??

And what file format pics are you trying to view? Make sure they are compatible etc size










#3 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 28 May 2006 - 02:20 PM

[!--quoteo(post=377779:date=May 28 2006, 04:18 AM:name=wild_dog)--][div class=\'quotetop\']QUOTE(wild_dog @ May 28 2006, 04:18 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Where is the html that reads the location of the pictures??

And what file format pics are you trying to view? Make sure they are compatible etc size
[/quote]

<img border=0 src=listingphoto/$row[4] width=281 height=283>";
}
?>
"Syntax error" .. WHERE THE **** IS IT?!

#4 Ferenc

Ferenc
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts

Posted 28 May 2006 - 05:58 PM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<img border=0 src=listingphoto/$row[4] width=281 height=283>[/quote]

The html is incorrect, thus the image is not displayed.

When you are testing the page view the source. It will show the incorrect path to the image.

it should look something like...
echo "<img src=\"listingphoto/". $row['4'] ."\" width=\"28\" height = \"283\" border=\"0\" >";
Everything you want to know is here.

#5 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 28 May 2006 - 06:23 PM

Viewing the html source may well tell you what the problem is.

The name of the pictures could also be a problem. Good old Windoze will let you name something "21 Main Street.jpg" but that isn't going to work from the server. You should probably consider renaming images - both uploaded and in the database - to use the underscore character in place of spaces or %20 in the names .... 21_Main_Street.jpg. The str_replace function will allow you to replace those spaces.
Legend has it that reading the manual never killed anyone.
My site

#6 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 29 May 2006 - 12:47 AM

[!--quoteo(post=377894:date=May 28 2006, 01:23 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 28 2006, 01:23 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Viewing the html source may well tell you what the problem is.

The name of the pictures could also be a problem. Good old Windoze will let you name something "21 Main Street.jpg" but that isn't going to work from the server. You should probably consider renaming images - both uploaded and in the database - to use the underscore character in place of spaces or %20 in the names .... 21_Main_Street.jpg. The str_replace function will allow you to replace those spaces.
[/quote]

no still wont work heres the link to the page...the pictures right where it says it is in the source but if you look at the pic properties everythings unknown

[a href=\"http://www.mattswebpage.com/subsite/listing.php?id=23\" target=\"_blank\"]http://www.mattswebpage.com/subsite/listing.php?id=23[/a]
"Syntax error" .. WHERE THE **** IS IT?!

#7 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 29 May 2006 - 12:59 AM

[!--quoteo(post=377946:date=May 28 2006, 07:47 PM:name=legohead6)--][div class=\'quotetop\']QUOTE(legohead6 @ May 28 2006, 07:47 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
no still wont work heres the link to the page...the pictures right where it says it is in the source but if you look at the pic properties everythings unknown

[a href=\"http://www.mattswebpage.com/subsite/listing.php?id=23\" target=\"_blank\"]http://www.mattswebpage.com/subsite/listing.php?id=23[/a]
[/quote]

wow! i changed echo to print and know most of the properties are showing up except type and size.... and mime_content_type doesnt work on my version of php 4.3.1
"Syntax error" .. WHERE THE **** IS IT?!

#8 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 29 May 2006 - 01:06 AM

This is confusing to say the least. Your original code had listingphoto as the folder where these images were supposed to be. Now the example you gave as a link presumes the image will be in a folder named subsite. And the image you give as the link shows as a missing image so I really doubt it's called what you think and/or saved where you think. Are you sure all the scripts (and the image) have been uploaded to your server and match the code you've given?
Legend has it that reading the manual never killed anyone.
My site

#9 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 29 May 2006 - 01:29 AM

[!--quoteo(post=377955:date=May 28 2006, 08:06 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 28 2006, 08:06 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
This is confusing to say the least. Your original code had listingphoto as the folder where these images were supposed to be. Now the example you gave as a link presumes the image will be in a folder named subsite. And the image you give as the link shows as a missing image so I really doubt it's called what you think and/or saved where you think. Are you sure all the scripts (and the image) have been uploaded to your server and match the code you've given?
[/quote]

sorry ive been fiddleing with it alot latly here is up to date codes

upload page
<?PHP
session_start();
$errors = array();
$user=$_SESSION['user'];

echo "<a href=home.php>Return Home</a>";
if(empty($_POST['ti'])){
        $errors[] = '<p><font color=\"yellow\">*Please enter a Title!</font></p>';
        }else{
        $ti=$_POST['ti'];
        }
        if(empty($_POST['pr'])){
        $errors[] = '<p><font color=\"yellow\">*Please enter a Price!</font></p>';
        }else{
        $pr=$_POST['pr'];
        }
        
        if(empty($_POST['de'])){
        $errors[] = '<p><font color=\"yellow\">*Please enter a Description!</font></p>';
        }else{
        $de=$_POST['de'];
        }
        if(move_uploaded_file($_FILES['ph']['tmp_name'], 
        "images/{$_FILES['ph']['name']}")){
        }else{
         $errors[] = '<p><font color=\"yellow\">*Sorry There was a Problem Uploading Your Picture, Please Try again!</font></p>';
        }
if(isset($_POST['submit'])){
if (empty($errors)) {
$username="*******";
$password="********";
$database="mattswebpage_com_-_web";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
 echo "<br><br>Your Listing Was successfully Posted!";
$query2="INSERT INTO listings VALUES('','$ti','$pr','$de','{$_FILES['ph']['name']}','$user')";
$result2 = mysql_query($query2) or die ("Error in query: $query2. ".mysql_error());
    }else{
foreach ($errors as $key){
echo "$key";
}
}
    }
    echo "<form enctype=multipart/form-data method=post>
    <p>Title:<input type=text name=ti size=20></p>
    <p>Price:<input type=text name=pr size=12></p>
    <p>Photo:<input type=file name=ph size=20></p>
    <p>Description:<br>
    <textarea rows=5 name=de cols=23></textarea></p>
    <p><input type=submit value=Submit name=submit></p>
</form>";
?>

and the view page
<?PHP
session_start();

$id=$_GET['id'];
$user=$_SESSION['user'];
$username="**********";
$password="***********";
$database="mattswebpage_com_-_web";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query2="SELECT * FROM listings WHERE id='$id'";

$result2 = mysql_query($query2) or die ("Error in query: $query2. ".mysql_error());
$num = mysql_num_rows ($result2);

echo "<p align=center>Welcome $user! <font size=2>Not you? <a href=login.php>Sign in!</a></font><br><a href=home.php>Return Home</a><br><br>";
while($row = mysql_fetch_row($result2)){
echo "<title>$row[1]</title>";
print("<font size=4>$row[1]</font><br><br><b>Listed By:</b> $row[5]<br><Br><b>Price:</b> $$row[2]<br><br><b>Description:</b><br>$row[3]<br><br>
<img src='http://www.mattswebpage.com/subsite/images/{$row['4']}' border=0 >");

}
?>

and heres a link to a test page

[a href=\"http://www.mattswebpage.com/subsite/listing.php?id=27\" target=\"_blank\"]http://www.mattswebpage.com/subsite/listing.php?id=27[/a]
"Syntax error" .. WHERE THE **** IS IT?!

#10 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 29 May 2006 - 01:43 AM

Your test page gives the (missing) image URL as [a href=\"http://www.mattswebpage.com/\" target=\"_blank\"]http://www.mattswebpage.com/[/a]subsite/ paint.jpg

The upload script places images in a folder named images/ relative to wherever the script is running.

Those are different image folder names!!
Legend has it that reading the manual never killed anyone.
My site

#11 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 29 May 2006 - 02:18 AM

[!--quoteo(post=377965:date=May 28 2006, 08:43 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 28 2006, 08:43 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Your test page gives the (missing) image URL as [a href=\"http://www.mattswebpage.com/\" target=\"_blank\"]http://www.mattswebpage.com/[/a]subsite/ paint.jpg

The upload script places images in a folder named images/ relative to wherever the script is running.

Those are different image folder names!!
[/quote]

sorry all the pics i am trying are in all the folders..but i deleted them all know and there both set to [a href=\"http://www.mattswebpage.com/images/shop/$row\" target=\"_blank\"]http://www.mattswebpage.com/images/shop/$row[/a][4]

but i get this error when trying to upload

Warning: move_uploaded_file(http://www.mattswebp.../shop/Bliss.jpg): failed to open stream: HTTP wrapper does not support writeable connections. in /var/www/html/subsite/newlist.php on line 24

Warning: move_uploaded_file(): Unable to move '/tmp/phpNQRqjf' to 'http://www.mattswebp.../shop/Bliss.jpg' in /var/www/html/subsite/newlist.php on line 24

how do i fix it?
"Syntax error" .. WHERE THE **** IS IT?!

#12 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 29 May 2006 - 03:03 AM

[!--quoteo(post=377966:date=May 28 2006, 09:18 PM:name=legohead6)--][div class=\'quotetop\']QUOTE(legohead6 @ May 28 2006, 09:18 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
sorry all the pics i am trying are in all the folders..but i deleted them all know and there both set to [a href=\"http://www.mattswebpage.com/images/shop/$row\" target=\"_blank\"]http://www.mattswebpage.com/images/shop/$row[/a][4]

but i get this error when trying to upload

Warning: move_uploaded_file(http://www.mattswebpage.com/images/shop/Bliss.jpg): failed to open stream: HTTP wrapper does not support writeable connections. in /var/www/html/subsite/newlist.php on line 24

Warning: move_uploaded_file(): Unable to move '/tmp/phpNQRqjf' to 'http://www.mattswebpage.com/images/shop/Bliss.jpg' in /var/www/html/subsite/newlist.php on line 24

how do i fix it?
[/quote]


i think i found the problem...look..this is the desination folder of the pics and this is one of the pics i uploaded

[a href=\"http://www.mattswebpage.com/images/shop/Bliss.jpg\" target=\"_blank\"]http://www.mattswebpage.com/images/shop/Bliss.jpg[/a]

how do i fix the forbidden thing?


"Syntax error" .. WHERE THE **** IS IT?!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users