Jump to content

corc

Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Posts posted by corc

  1. Alright so I've got this really simple script:
    [code]<table width="80%" cellpadding="0" cellspacing="0" border="0" class="news">
    <tr><td><b>Meet Name:</b></td><td><b>Date:</b></td><td><b>Location:</b></td><td><b>Results:</b></td></tr>

    <?php

    // Display current schedule
    include("./pk2/db.php");
    include("./pk2/db2.php");

    $readschedule = 'SELECT event, date, date_int, location, res_query, res_link FROM park_schedule ORDER BY date_int

    ASC';

    if ($readsched1 = mysql_query ($readschedule)) {
    while ($row = mysql_fetch_array ($readsched1)) {
    print ("<tr>\n");
    print ("<td>{$row['event']}</td>\n");
    print ("<td>{$row['date']}</td>\n");
    print ("<td>{$row['location']}</td>\n");
    print ("<td>");
    // If results posted, make link.
    if ({$row['res_query']} == 1) {
    print ("<a href=\"{$row['res_link']}\">Results</a>");
    } else {
    print ("Results Not Available");
    }
    print ("</td>\n</tr>");
    }
    } else {
    die ('<p>Could not retrieve the data because: <b>' . mysql_error() . "</b></p><p>The query

    was:<br>$readschedule</p>");
    }

    mysql_close();

    ?>
    </table>[/code]

    And there's some stupid little typo in it somewhere that's causing it to not work. I just need a little help finding it..I've been staring at this for like 2 hours now.
  2. [code]<?php phpinfo(); ?>[/code]

    Put that in a file and name it phpinfo.php or something then upload and then browse to it. Look for the line that says "upload_max_filesize". That will tell you the maximum upload size set in your .ini
  3. Ok, so I'm working on a script, very simple, that uses four form elements. A file (image) upload, First name, Last name, and year (school year..freshman, sophomore, junior, senior). What I need to happen is for the first name, last name, year, and image name elements to be inserted into a mysql database. The image also needs to be uploaded, and the filename changed to essentially firstnamelastname.jpg (assuming it's a jpg file). I can get the file to upload, but it retains the original filename. I can get the form elements to post to the database (not a problem for me, just haven't written that part yet). So I need to figure out:

    1. How to change the filename.
    2. Check for a jpg image type.
    3. If possible, avoid having to chmod a directory to 777 for all this to work.
    4. Maybe a little security?

    Here's what I've got so far, it's sloppy..I apologize:

    [code]
    <?php
    // Set Upload Directory
    $uploadtmpdir = '';
    $uploaddir = '';

    // Error Handling
    ini_set ('display_errors', 1);
    ini_set ('upload_tmp_dir','$uploadtmpdir');
    error_reporting (E_ALL & ~E_NOTICE);

    // Check for submission
    if (isset ($_POST['submit'])) {
    $writebio = "INSERT INTO park_bios (first_name, last_name, year) VALUES ('{$_POST['firstname']}', '{$_POST['lastname']}', '{$_POST['year']}')";

    if (move_uploaded_file ($_FILES['thefile']['tmp_name'], "{$uploaddir}/{$_FILES['thefile']['name']}")) {
    print($_FILES['name']);
    print ("<p>Your file has been uploaded</p>");
    $writepic = "UPDATE park_bios SET pic='{$_POST['posttitle2']}', content='{$_POST['postcontent2']}', poster='{$_POST['poster2']}' WHERE news_id='{$_POST['enewsset']}'";

    } else {

    print ("<p>Your file could not be uploaded because: <b>");

    switch ($_FILES['thefile']['error']) {
    case 1:
    print 'The file exceeds the upload_max_filesize setting in php.ini';
    break;
    case 2:
    print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form';
    break;
    case 3:
    print 'The file was only partially uploaded';
    break;
    case 4:
    print 'No file uploaded';
    break;
    }

    }

    }

    ?>

    <form action="uploadfile01.php" enctype="multipart/form-data" method="post">
    <p>Upload a file using this form: <br /><br />
    <input type="hidden" name="MAX_FILE_SIZE" value="500000" />
    <input type="file" name="thefile" /><br /><br />
    First Name: <input type="text" size="20" name="firstname" /><br /><br />
    Last Name: <input type="text" size="20" name="lastname" /><br /><br />
    <input type="submit" name="submit" value="Upload this file" />
    </p>
    </form>
    [/code]

    Any suggestions? I've looked through some old topics on similar issues, but most of them make it more complicated than I think it needs to be.
×
×
  • Create New...

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.