Closed Thread Icon

Topic awaiting preservation: What have I done wrong this time? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=29056" title="Pages that link to Topic awaiting preservation: What have I done wrong this time? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: What have I done wrong this time? <span class="small">(Page 1 of 1)</span>\

 
Victoria Draken
Obsessive-Compulsive (I) Inmate

From: A Library Dungeon
Insane since: Feb 2007

posted posted 03-20-2007 06:35

Sorry to be a gigantic problem in everyone's butt... But I've followed yet another tutorial for a PHP Image Gallery only for nothing to work! I go to upload the image, hit "submit" and then the file and description disappear with nothing happening! No uploading or anything!

All my files can be viewed here:
http://reference-desk.net/pictures/other

The tutorial is here:
http://www.onlamp.com/pub/a/onlamp/2002/05/09/webdb2.html?page=1

And the code for my index.php is:

code:
<!DOCTYPE HTML PUBLIC 
  "-//W3C//DTD HTML 4.0 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   <title>Browse Upload Files</title>
</head>
<body bgcolor="white">

<?php
  include 'db.inc';
  
  $query = "SELECT id, shortName, mimeName FROM gallery";

  if (!($connection = @ mysql_pconnect($hostName, 
                                    $username,
                                    $password)))
     showerror();

  if (!mysql_select_db("tutorial", $connection))
     showerror();
        
  if (!($result = @ mysql_query ($query, $connection)))
     showerror();
?>
    <h1>Image database</h1> 

    <h3>Click <a href="insert.php">here</a> to 
upload an image.</h3>
<?php 
 

  if ($row = @ mysql_fetch_array($result))
  {
?>

    <table>
    <col span="1" align="right">
    <tr>
       <th>Short description</th>
       <th>File type</th>
       <th>Image</th>

    </tr>
<?php
   do 
   {
?>
    <tr>
       <td><?php echo "{$row["shortName"]}";?></td>         
       <td><?php echo "{$row["mimeName"]}";?></td>
       <td><?php echo "<img src=\"view.php?file={$row["id"]}\">";?></td>
    </tr>
<?php
   } while ($row = @ mysql_fetch_array($result));
?>
    </table>
<?php
  } // if mysql_fetch_array()
  else
     echo "<h3>There are no images to display</h3>\n";
?>
</body>
</html>


-
- -
- - -
- -
-

The truth is just an excuse for a lack of imagination. -

Elim Garak, Star Trek : Deep Space Nine


Edit TP: Closing code tag...

(Edited by Tyberius Prime on 03-20-2007 11:14)

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 03-20-2007 11:16

First off, get rid of the @s - you don't want to hide your errors, you want to see them!

Second, you need to show us all your code - we can't read your php code on your server if it's named '.php'.

So long,

->Tyberius Prime

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 03-20-2007 13:35

If you don't want to paste the code here (which is probably a good idea if there's a lot of it) then you can make copies of the files, but with the extension .phps. This will tell your webserver to send them to the PHP interpretor as source files, and it in turn will display it for us to see, all nicely syntax highlighted.


Justice 4 Pat Richard

Victoria Draken
Obsessive-Compulsive (I) Inmate

From: A Library Dungeon
Insane since: Feb 2007

posted posted 03-21-2007 02:15

Ha, and here I was thinking I was being so smart moving them into a directory away from the index... I didn't even think that you guys couldn't read it! I also renamed the .inc file because I wasn't sure about that one.

Tyberius: I don't understand the meaning of "@", why would it hide my errors?

-
- -
- - -
- -
-

The truth is just an excuse for a lack of imagination. -

Elim Garak, Star Trek : Deep Space Nine

(Edited by Victoria Draken on 03-21-2007 02:16)

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 03-21-2007 11:43

@ is an interpreter signal in PHP. It says "supress any error messages this function may produce" because (it assumes) you're going ot handle those yourself.


Justice 4 Pat Richard

Victoria Draken
Obsessive-Compulsive (I) Inmate

From: A Library Dungeon
Insane since: Feb 2007

posted posted 03-22-2007 00:24

Ohhhhh... Thanks! I'll get right to removing them...

Edit: Done. Working version is here:
http://reference-desk.net/pictures/index.php

And viewable files still as above. Still having same problem and no error codes.

-
- -
- - -
- -
-

The truth is just an excuse for a lack of imagination. -

Elim Garak, Star Trek : Deep Space Nine

(Edited by Victoria Draken on 03-22-2007 00:32)

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 03-22-2007 20:24

Okay it's probably an error with the insert.php file

Try changing instances of $short and $userfile with $_POST['short'] and $_POST['userfile']

I'm thinking you don't have register_globals on (which is good)

oh and if that doesn't work try putting

error_reporting(E_ALL);

on the top of your pages.



.:[ Never resist a perfect moment ]:.

(Edited by bitdamaged on 03-22-2007 20:25)

Victoria Draken
Obsessive-Compulsive (I) Inmate

From: A Library Dungeon
Insane since: Feb 2007

posted posted 03-23-2007 03:47

What is "error_reporting(E_ALL);" supposed to do? I've done what you suggested with the $short and $userfile and I've added the error reporting, but it's still doing it

Thank you for all your help though! Still open to anymore suggestions people might have! (files still at locations stated above)

-
- -
- - -
- -
-

The truth is just an excuse for a lack of imagination. -

Elim Garak, Star Trek : Deep Space Nine

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 03-23-2007 16:38

php->error_reporting ( that link goes to the manual) makes sure you can actually see the errors and warnings your script encounters.


now to the real deal...

Your file info isn't stored in post.
It's stored in $_FILES.
And once you have that, you need to do
is_uploaded_file($_FILES['tmp_name']) - that function requires the actual file on disc ( as php->is_uploaded_file says ).

next stop would be to use php->copy to copy the file some place sensible instead of storing in in the db (storing any number of files
in a mysql database is a sure fire way to drop performance to a minimum - ie. don't do that. Keep files in the file system, insert meta information
about it into the database (do that first, and you can name the saved file after the id in the meta information table).

Hope this get's you going,
So long,

->Tyberius Prime

« BackwardsOnwards »

Show Forum Drop Down Menu