Jump to content

Recommended Posts

I hate MYSQL. Here's the query...

 

<?php
$query = mysql_query("UPDATE gs_mem SET mem_avx='$extension' WHERE mem_id='$whichid'");
$result = mysql_query($query) or die(mysql_error());
?>

 

Here's the file it is from...

 

<?php

session_start();
include("connect.php");
include("functions.php");

$whichid = $_SESSION['mem_id'];

// the code below is just a quick webpage, don't use it for proper thing

if (!$_FILES['file_loc']) die('<html><head><title><body><p>Upload a <i>.jpg/.gif/.png/.bmp</i> image for your avatar:</p><form enctype="multipart/form-data" method="post" action=""><input type="file" name="file_loc" /><br><input type="submit" value="Upload Avatar" /></form></body></html>');

// the PHP below is to process the form. copy and paste it where it's needed

if ($_FILES['file_loc']['size'] <= 200000) {

   $file_type_arr = explode(".", $_FILES['file_loc']['name']);
   $extension = $file_type_arr[1];

   $file_types = array("jpg","jpeg","gif","png","bmp");
   if (array_search($extension, $file_types) != "") {

      if (move_uploaded_file($_FILES['file_loc']['tmp_name'], 'img/avatars/'.substr($_SESSION['mem_id'],0,1).'/'.$_SESSION['mem_id'].'.'.$extension)) {
	 print 'Extension: '.$extension.'<br />';
         print 'File size: '.$_FILES['file_loc']['size'].'<br />';
         print 'File type: '.$_FILES['file_loc']['type'].'<br />';
         print 'File was uploaded successfully. Click here to view it <a href="'.$new_loc.'" target="_blank">'.$new_loc.'</a>';

         $query = mysql_query("UPDATE gs_mem SET mem_avx='$extension' WHERE mem_id='$whichid'");
	 $result = mysql_query($query) or die(mysql_error());

      } else print "Error uploading image!";
   } else print "Invalid image type! (".$extension."!)";
} else print "Invalid file size!";

?>

Link to comment
https://forums.phpfreaks.com/topic/65170-solved-mysql-problem-again/
Share on other sites

Don't just throw code at us. Explain your problem (it was blindingly obvious in your code this time).

 

Change:

$query = mysql_query("UPDATE gs_mem SET mem_avx='$extension' WHERE mem_id='$whichid'");
$result = mysql_query($query) or die(mysql_error());

 

To:

$query = "UPDATE gs_mem SET mem_avx='$extension' WHERE mem_id='$whichid'";
$result = mysql_query($query) or die(mysql_error());

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.