Jump to content

stouffers3

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

stouffers3's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am not getting an error. I get "your image has been uploaded". But when I go to the database the old image is there, nothing has changed. M update page code: <?php require_once('../Connections/mydatabase.php'); ?> <?php $colname_image = "-1"; if (isset($_GET['username'])) { $colname_image = (get_magic_quotes_gpc()) ? $_GET['username'] : addslashes($_GET['username']); } mysql_select_db($database_mydatabase, $mydatabase); $query_image = sprintf("SELECT * FROM binary_data WHERE username = '%s'", $colname_image); $image = mysql_query($query_image, $mydatabase) or die(mysql_error()); $row_image = mysql_fetch_assoc($image); $totalRows_image = mysql_num_rows($image); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <p>Image uploaded for: <?php echo $row_image['username']; ?> <?php // code that will be executed if the form has been submitted: if ($submit) { // connect to the database mysql_select_db($database_mydatabase, $myspace); $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data))); $result=MYSQL_QUERY("UPDATE binary_data SET(bin_data,filename,filesize,filetype) ". "VALUES ('$data','$form_data_name','$form_data_size','$form_data_type')"); print "<p>Your image has been uploaded"; MYSQL_CLOSE(); } else { ?></p> <p><form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000"> <table width="300" border="0" cellspacing="0" cellpadding="0"><tr> <td align="right">Image:</td> <td><input type="file" name="form_data" size="40"></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="submit" ></td> </tr> </table> <br> <br> <p> </form></p> <?php } ?> </body> </html> <?php mysql_free_result($image); ?> I don't know what else to do. Please help
  2. I have a page that I use for users on my site to upload an image (displayed on their personal page). I am trying to figure out how I can update/replace the image in the database so that they can change their image. Can binary data be updated? Here's the code for my upload script: <?php // code that will be executed if the form has been submitted: if ($submit) { // connect to the database mysql_select_db($database_mydatabase, $mydatabase); $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data))); $result=MYSQL_QUERY("INSERT INTO binary_data (username, bin_data,filename,filesize,filetype) ". "VALUES ('$username','$data','$form_data_name','$form_data_size','$form_data_type')"); print "<p>Your image has been uploaded"; MYSQL_CLOSE(); } else { ?> </p> <form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000"> <table width="300" border="0" cellspacing="0" cellpadding="0"> <tr> <td>Username:</td> <td><input type="text" name="username" /></td> <tr> <td align="right">Image:</td> <td><input type="file" name="form_data" size="40"></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="submit" ></td> </tr> </table> <br> <br> <p> </form> <?php } ?> I tried using UPDATE ... SET ... but that won't work. PS. If I can't update binary data, are there any suggestions of how my users could change their picture. One thing I've thought of is on upload renaming the image with the user's username?? Thanks
×
×
  • 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.