Thread: Freaky problem!

    #1
  1. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    17
    I am writing an article storing script. As part of the article, the user can include a diagram, but I want this diagram to only be in GIF format, so I have put this check in place. However, when I try and submit a GIF, it fails the GIF-checking function. Which is odd. But now here's the even wierder bit: when I take everything out of the form apart from the <input type=file name=file< it works, and the GIF passes the error checking!!!! Please someone help as this is driving me round the bend.

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>

    <?

    if ($cmd == "add") {

    ?>

    <html>
    <head>
    <title>Noticeboard</title>

    <link rel="stylesheet" type="text/css" href="../default.css">
    <script language="JavaScript" src="pop.js"></script>

    <body background="../bg.jpg" bgcolor="#FFFFFF" class="bg" link="#2799F1" vlink="#2799F1" alink="#2799F1">

    <form method="POST" enctype="multipart/form-data" action="article.php3?cmd=do_add">

    <table border="0">
    <tr>
    <td valign="middle">
    <h1 class=heading>Add a strategy</h1>
    </td>
    <td valign="baseline" align="left"><img src="shim.gif" width="15" height="1"></td>
    <td valign="baseline" align="left"><a href="javascript:newWindow('help.html', 'a', 480, 600, 1)"><img src="help.gif" width="73" height="23" border="0"></a></td>
    </tr>
    </table>
    <p><font face="Arial, Helvetica, sans-serif">To add a strategy, complete this
    form and click on Submit when you are finished.</font></p>
    <p><font face="Arial, Helvetica, sans-serif">Please note that if you choose
    to include a channel diagram, it must conform to this key:</font></p>
    <table border="0" cellspacing="3" cellpadding="0">
    <tr>
    <td>*</td>
    <td>
    <p><img src="key.gif" width="356" height="293"></p>
    <p>*</p>
    </td>
    </tr>
    <tr>
    <td><font face="Arial, Helvetica, sans-serif">Name:</font></td>
    <td>
    <input type="text" name="name" class=formelement>
    </td>
    </tr>
    <tr>
    <td><font face="Arial, Helvetica, sans-serif">Email:</font></td>
    <td>
    <input type="text" name="email" class=formelement>
    </td>
    </tr>
    <tr>
    <td><font face="Arial, Helvetica, sans-serif">Club/School:</font></td>
    <td>
    <input type="text" name="club" class=formelement>
    </td>
    </tr>
    <tr>
    <td><font face="Arial, Helvetica, sans-serif">Subject:</font></td>
    <td>
    <input type="text" name="subject" class=formelement>
    </td>
    </tr>
    <tr>
    <td><font face="Arial, Helvetica, sans-serif">Age range:</font></td>
    <td>
    <select name="section" class=formelement>
    <option value="youth">Youth Rugby</option>
    <option value="schools">Schools & Colts</option>
    <option value="seniors">Seniors</option>
    </select>
    </td>
    </tr>
    <tr>
    <td valign="top"><font face="Arial, Helvetica, sans-serif">Problem:</font></td>
    <td>
    <textarea name="problem" cols="45" rows="10" class=formelement></textarea>
    </td>
    </tr>
    <tr>
    <td valign="top"><font face="Arial, Helvetica, sans-serif">Solution:</font></td>
    <td>
    <textarea name="solution" cols="45" rows="10" class=formelement></textarea>
    </td>
    </tr>
    <tr>
    <td><font face="Arial, Helvetica, sans-serif">Diagram:</font></td>
    <td>
    <input type="file" name="file" class=formelement>
    </td>
    </tr>
    <tr>
    <td valign="top"><font face="Arial, Helvetica, sans-serif">Diagram explanation:</font></td>
    <td>
    <textarea name="explanation" cols="45" rows="10" class=formelement></textarea>
    </td>
    </tr>
    <tr>
    <td valign="top"><font face="Arial, Helvetica, sans-serif">Coaching points::</font></td>
    <td>
    <textarea name="coaching" cols="45" rows="10" class=formelement></textarea>
    </td>
    </tr>
    <tr>
    <td>*</td>
    <td>
    <input type="submit" value="Submit" name="submit" class="button">
    <input type="reset" value="Reset" name="reset" class="button">
    </td>
    </tr>
    </table>
    </form>

    </body></html>


    <?

    }

    elseif ($cmd == "do_add") {

    MYSQL_CONNECT(localhost,user,pass) OR DIE("Unable to connect to database");

    @mysql_select_db("db") or die("Unable to select database");

    $id = uniqid(date("U"));
    /*
    $channel = "0";

    if {isset($file)) {

    $channel = "1";

    }
    */

    $channel = "1";

    $time = (date("G:i"));
    $date = (date("dS F, Y"));

    if ($file_type == "image/gif") {

    $query = "INSERT INTO articles (name,email,club,problem,solution,id,section,date,time,subject,explanation,coaching,channel) VALUES ('$name', '$email', '$club', '$problem', '$solution', '$id', '$section', '$date', '$time', '$subject', '$explanation', '$coaching', '$channel')";

    $result = mysql_query ($query);

    if ($result) {

    copy($file,"/usr/users/g25n36rj/public_html/irtest/images/$id.gif");
    echo "<META HTTP-EQUIV="Refresh" content="0;article.php3?section=$section">";

    /* Debug section
    print "Article added<br>.";
    print "The SQL statement was:<p> $query<br>";
    print "And the result was:<p> $result<br>";
    print "The section was $section<br>";
    print "Click <a href="ideas.php3?section=$section">here</a> to go to the section the article's in";
    */

    }

    else {

    print "Boog.<p>This was the query: <p>$query<p>And for some hopefully-apparent reason it wasn't inserted<p>MySQL said:<br>";
    echo mysql_error();
    }

    }

    else {

    print "Please submit your channel in GIF format. <br><a href="javascript:history.back();">Back</a><br>You submitted your channel in $file_type format";
    }

    MYSQL_CLOSE();

    }

    ?>

    [/code]

    HEEEEEELLLLPPPPPPPPP!!!

    --------------------------------------------
    Alex
    (http://www.alex-greg.co.uk)


    [This message has been edited by alexgreg (edited September 24, 2000).]
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    Not sure why that didn't work, but a slight workaround wou be to grab the last 4 charcaters from the end of the $file_name and make sure it is .GIF or .gif

    by using
    $ext = substr($file_name, -4, strlen($file_name));
    if (($ext == ".GIF") &#0124; &#0124; ($ext == ".gif")) {
    //gif present
    }
    else {
    //No gif
    }
  4. #3
  5. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    17
    OK thanks, I've put that in the script but it still hasn't solved the problem. When it fails the test, it says,

    Please submit your channel in .GIF format
    Back
    You submitted your channel in format

    i.e., the variable that stores the format isn't getting set for some reason. Any ideas why, and any ideas why it DOES get set with a shorter form?? (which is the really odd part)

    --------------------------------------------
    Alex
    (http://www.alex-greg.co.uk)

Similar Threads

  1. Replies: 5
    Last Post: February 2nd, 2005, 12:28 AM
  2. UTF-8 problem in 4.1.1a
    By mehran20 in forum MySQL Help
    Replies: 1
    Last Post: February 8th, 2004, 02:21 PM
  3. fread problem: doesn t compile php code
    By ghorghor2002 in forum PHP Development
    Replies: 2
    Last Post: February 3rd, 2004, 05:25 AM
  4. WinNT4 problem
    By sandipguha in forum Windows Help
    Replies: 0
    Last Post: January 27th, 2004, 02:06 AM
  5. weird java problem..please help
    By suwandy in forum Java Help
    Replies: 1
    Last Post: January 26th, 2004, 04:13 AM

IMN logo majestic logo threadwatch logo seochat tools logo