Jump to content

Problems with insert query please help (URGENT)


radiations3

Recommended Posts

HI,

The following code is performing the right functionality of moving an image into the specified folder but what its not doing is inserting the file saved path into the mentioned table into the database kindly help me with that how can i do it..

 

 

 

 

FORM.php

 

<form action="upload.php" method="post" enctype="multipart/form-data">

  <p>File:

    <input type="file" name="filename" />

  </p>

 

  <p>

    <input type="submit" value="Upload" />

      </p>

</form>

 

UPLOAD.php

 

<?php require_once('Connections/hammad.php'); ?>

 

<?php

 

$folder = "pak/".$_FILES['filename']['name'];

 

  $n=0;

 

mysql_select_db($database_hammad,$hammad) or die(mysql_error());

mysql_query("INSERT INTO blob (id,pic) VALUES ('$n', '$folder')");

 

 

 

if (is_uploaded_file($_FILES['filename']['tmp_name']))  { 

    if (move_uploaded_file($_FILES['filename']['tmp_name'], $folder)) {

     

Echo "File uploaded";

    } else {

        Echo "file not moved to destination folder. Check permissions";

    };

} else {

    Echo "File is not uploaded.";

};

 

?>

 

 

 

Link to comment
Share on other sites

Reading them would be a GREAT way to find that out.

 

Now that I've made you wait, what happens when I upload a file with a name like Falken's Maze?

if($help == 'yes')

echo 'okay if you can help then that'll be so nice of you' ;

else

echo 'no problem have a nice day!';

Link to comment
Share on other sites

add this: or die(mysql_error());

to this: mysql_query("INSERT INTO blob (id,pic) VALUES ('$n', '$folder')");

 

and you will find the error but my next guess would be that your ID is an auto increment primary key and you're setting it to 0 every time which is incorrect because ID values can not duplicate

Link to comment
Share on other sites

add this: or die(mysql_error());

to this: mysql_query("INSERT INTO blob (id,pic) VALUES ('$n', '$folder')");

 

and you will find the error but my next guess would be that your ID is an auto increment primary key and you're setting it to 0 every time which is incorrect because ID values can not duplicate

 

 

I am pretty much close to solve this problem kindly help me with this not after adding that die fnction its displaying following error message

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''blob' (id,pic) VALUES ('1', 'pak/2010 Toyota iQ.jpg')' at line 1

 

mysql_query("INSERT INTO 'blob' (id,pic) VALUES ('$n', '$folder')") or die(mysql_error());

Link to comment
Share on other sites

this is incorrect: mysql_query("INSERT INTO 'blob' (id,pic) VALUES ('$n', '$folder')") or die(mysql_error());

this is correct:  mysql_query("INSERT INTO `blob` (`id`,`pic`) VALUES ('$n', '$folder')") or die(mysql_error());

 

THANK YOU VERY MUCH MY ISSUE IS BEING RESOLVED THANKS ALOTTT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

ONE MORE QUESTION CAN YOU PLEASE HELP ME WITH DISPLAYING OF IMAGE FROM BLOB FIELD....

Link to comment
Share on other sites

I can't help you with that right now because I'm really short on time and got to go, but google "image blob field" and you'll probably find the solution

 

No problem .. and thanx for helping me out.. if u get some time then do help me with blob field to display image i googled it but what ever solution was given i could not be able to make it work on my server so that's why i am seeking solutions here and i got one as well Thanks to God (1st) & to you!!!!

Link to comment
Share on other sites

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.