mySQL uploading problem

Discussion in 'Web Design & Coding' started by JeremyT, Sep 6, 2003.

  1. JeremyT

    JeremyT Guest

    I'm not really sure where to put this so i just threw it here :(

    Problem: I cannot upload anything via a PHP script such as vBulletin/paFileDB/phpBB.

    If I use the fput() funcion or similiar which does not interact with MySQL in any way it is fine also with FTP I am fine.

    my PHP.ini info can be found at http://www.clan1g.com/phpinfo.php

    The server admins have been taking forever to figure the problem out and it's been 2 weeks and it's still not fixed. Nothing has changed on my end as far as I know which makes me 99% sure it is a problem with the server and more specifically MySQL.

    I recently installed vBulletin and it worked fine for two days, after that all my scripts suddenly wouldn't work so I am positive it is also not a script error, like I said, I changed nothing.

    Edit: Also, sometimes vB will appear to attach a file but it really does not, shows 0k. For those of you wondering vB stores the file data in a MySQL table while pafileDB/phpBB put them onto the FTP, but both need to go through SQL first. /edit

    Any help is greatly greatly appreciated.
    JeremyT
     
  2. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    The info looks ok to me. Uploads are turned on, the temp folder looks ok and the max file size is at least 2MB.
     
  3. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    PHP:
    <?php
    ###VARS#######
    $passprotect=true;//protect uploader w/ password?
    $pass="idiot";//password if so
    ###END VARS###


    ini_set("upload_max_filesize""8M");
    ini_set("post_max_size","8M");
    ini_set("file_uploads","1");
    ###########################
    if(empty($HTTP_POST_VARS['password']))$password="";
    else 
    $password=$HTTP_POST_VARS['password'];
    if(isset(
    $HTTP_COOKIE_VARS['password'])&&$password!=$pass)$password=$HTTP_COOKIE_VARS['password'];
    #=========================#
    $basedir="others/upload/";
    if(empty(
    $HTTP_POST_VARS['n']))$n=5;
    else 
    $n=$HTTP_POST_VARS['n'];
    ###########################
    if($passprotect)
    {
    if(
    $password==$pass){$allow=true;setcookie("password",$pass,time()+3600*24*20);}
    else 
    $allow=false;
    }
    else 
    $allow=true;
    ###########################
    echo "<html>
    <head><title>File Uploader</title></head>
    <body><form enctype=multipart/form-data action='"
    .$HTTP_SERVER_VARS['PHP_SELF']."' method=post><table>";
    if(isset(
    $HTTP_POST_VARS['submitted']))//if submitted
    {
        if(
    $allow)
        {
            
    $num=0;
            for(
    $i=1;$i<=$HTTP_POST_VARS['n'];$i++)
            {
                if(isset(
    $HTTP_POST_FILES['f'.$i]['name'])&&$HTTP_POST_FILES['f'.$i]['name']!="")
                {
                    
    $file=$basedir.$HTTP_POST_FILES['f'.$i]['name'];
                    if(@
    is_writable($basedir))
                    {
                        if(
    file_exists($file))unlink($file);
                        if(@
    move_uploaded_file($HTTP_POST_FILES['f'.$i]['tmp_name'], $file))
                        echo 
    "<tr><td>$i)</td><td>\"<a href=\"".$file."\" target=_blank>".$HTTP_POST_FILES['f'.$i]['name']."</a>\" uploaded</td></tr>";
                        else echo 
    "<tr><td>$i)</td><td>Can not upload \"".$HTTP_POST_FILES['f'.$i]['name']."\" .</td>\n";
                    }
                    else echo 
    "<tr><td>$i)</td><td>Can not upload \"".$HTTP_POST_FILES['f'.$i]['name']."\" .</td>\n";
                    
    $num++;
                }
            }
            if(!@
    is_writable($basedir))echo "<tr><td colspan=2>Please CHMOD the folder \"$basedir\" to 777!</td></tr>";
            if(
    $num!=0)echo "<tr><td colspan=2><hr></td></tr>\n";
        }
        else echo 
    "<tr><td colspan=2>Sorry, wrong password. Please try again.</td></tr>";
    }
    if(
    $passprotect)echo "<tr><td colspan=2>Password Required</td></tr><tr><td>Password:</td><td><input type=password name=password size=35 style=width:100% value=\"$password\"></td></tr>";
    echo 
    "
    <tr>
    <td>Show <input name=n size=1 value=
    $n style=border:0px;size:12pt;font-face:'Times New Roman'></td>
    <td>upload boxes : <input type=submit name=Show value=Show></td>
    </tr>"
    ;
    for(
    $i=1;$i<=$n;$i++) echo "
    <tr>
    <td>
    $i)</td>
    <td><input size=35 name=f
    $i type=file></td>
    </tr>\n"
    ;
    ?><tr>
    <td><input type=reset value=Reset></td>
    <td><input size=35 name=upload style=width:100% type=submit value=Upload><input type=hidden name=submitted value=true></td>
    </tr></table></form></body></html>
    Check out this code. If this works, then there might be a problem with your script.
     
  4. JeremyT

    JeremyT Guest

    Nope, that script does not work either. I am even more convinced it is server isse because the web based e-mail wont allow attachments now, and it would before.

    We are getting put on a new server so hopefully that fixes my problems. I would like to know what can cause a problem like this though, huge pain in the ass
     
  5. JeremyT

    JeremyT Guest

    Well the server changed did indeed fix all the problems so it was definatly something wrong with either php or MySQL
     
  6. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    I am betting my money on a faulty PHP install.
     
  7. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    Me too. I had a PHP version that would duplicate pretty much anything that was POST:ed to it. Very annoying!