Jump to content

Archived

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

legohead6

help with picture stuff

Recommended Posts

ok... heres the script that uploads(pictures show up in folder and open fine)
[code]
<?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>";
?>[/code]

and heres the page that should view them but the pics show up as x's!!
[code]
<?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>";
}
?>[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=377768:date=May 28 2006, 01:51 AM:name=legohead6)--][div class=\'quotetop\']QUOTE(legohead6 @ May 28 2006, 01:51 AM) [snapback]377768[/snapback][/div][div class=\'quotemain\'][!--quotec--]
ok... heres the script that uploads(pictures show up in folder and open fine)
[code]
<?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>";
?>[/code]

and heres the page that should view them but the pics show up as x's!!
[code]
<?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>";
}
?>[/code]
[/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








Share this post


Link to post
Share on other sites
[!--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) [snapback]377779[/snapback][/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>";
}
?>

Share this post


Link to post
Share on other sites
[!--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\" >";

Share this post


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

Share this post


Link to post
Share on other sites
[!--quoteo(post=377894:date=May 28 2006, 01:23 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 28 2006, 01:23 PM) [snapback]377894[/snapback][/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]

Share this post


Link to post
Share on other sites
[!--quoteo(post=377946:date=May 28 2006, 07:47 PM:name=legohead6)--][div class=\'quotetop\']QUOTE(legohead6 @ May 28 2006, 07:47 PM) [snapback]377946[/snapback][/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

Share this post


Link to post
Share on other sites
This is confusing to say the least. Your original code had [b]listingphoto[/b] 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 [b]subsite[/b]. 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?

Share this post


Link to post
Share on other sites
[!--quoteo(post=377955:date=May 28 2006, 08:06 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 28 2006, 08:06 PM) [snapback]377955[/snapback][/div][div class=\'quotemain\'][!--quotec--]
This is confusing to say the least. Your original code had [b]listingphoto[/b] 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 [b]subsite[/b]. 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
[code]<?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>";
?>[/code]

and the view page
[code]<?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 >");

}
?>[/code]

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]

Share this post


Link to post
Share on other sites
Your test page gives the (missing) image URL as [a href=\"http://www.mattswebpage.com/\" target=\"_blank\"]http://www.mattswebpage.com/[/a][b]subsite/[/b] paint.jpg

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

Those are different image folder names!!

Share this post


Link to post
Share on other sites
[!--quoteo(post=377965:date=May 28 2006, 08:43 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 28 2006, 08:43 PM) [snapback]377965[/snapback][/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][b]subsite/[/b] paint.jpg

The upload script places images in a folder named [b]images/[/b] 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.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?

Share this post


Link to post
Share on other sites
[!--quoteo(post=377966:date=May 28 2006, 09:18 PM:name=legohead6)--][div class=\'quotetop\']QUOTE(legohead6 @ May 28 2006, 09:18 PM) [snapback]377966[/snapback][/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?

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.