GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 20-Aug-2009, 07:57
dinno dinno is offline
New Member
 
Join Date: Aug 2009
Posts: 3
dinno is on a distinguished road
Smile

Image uploader


Hello everyone I have a problem with my upload when uploading I get this this message.

File has been uploadet: tastetur.jpg

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 '(billede,tekst) VALUES='tastetur.jpg','jjkk'' at line 1


My code looks like this

PHP Code:

<?php 
if (isset($_FILES['filnavn'])) {print "Fil der er blevet overført: {$_FILES['filnavn']['name']}<p>\n";
$tekst=$_POST['tekst'];    
    
$query = "INSERT INTO dagenstilbud SET(billede,tekst) VALUES='".$_FILES['filnavn']['name']."','$tekst'";
    $Result1 = mysql_query($query, $cms) or die(mysql_error());
    
}

{
$tempfile = $_FILES['filnavn']['tmp_name'];
$destination = "dagenstilbud/{$_FILES['filnavn']['name']}";
copy($tempfile, $destination);
}
?>
   <form method="POST" enctype="multipart/form-data" name="form1" id="form1"> 
   
<table width="100%" border="0" cellspacing="0" cellpadding="2">
       <tr>
         <td width="10%">&nbsp;</td>
         <td width="90%">
         <label>Indsæt reklamebillede</label></td>
       </tr>
       <tr>
         <td colspan="2">
          <p align="left">Fil der skal overføres:
             <label for="filnavn"></label>
             <input type="file" name="filnavn" id="filnavn" /><br />
             <label>tekst
             <input type="text" name="tekst" id="tekst" />
             </label>
          <label for="navn"></label>
          <label for="type"></label>
          </p>
        </td>
    </tr>
       <tr>
         <td colspan="2">
          <input type="submit" name="button" id="button" value="Overfør" /></td>
       </tr>
     </table>
    <p>
    <label></label>
    <span class="style9">
    <label></label>
    </span></p>
  <label></label>
  <p>
    <label></label>
  </p>
  
    
   
   <input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $row_rsmitbilled['id']; ?>" />
</form>

I really hope that there is one who can tell me what goes wrong.
Thank you in advance
dinno
Last edited by LuciWiz : 20-Aug-2009 at 09:18. Reason: Please insert your Php code between [php] & [/php] tags
  #2  
Old 20-Aug-2009, 21:53
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: image uploader


You have crossed the syntax of an INSERT statement with part of an UPDATE statement, but you are close...

The generic form for an INSERT or UPDATE is:
Code:
INSERT INTO table( column_list ) VALUES( column_values ); UPDATE table SET col1=value, col2=value, coln=value WHERE <condition>

So, in your SQL, the 'SET' needs removal:
PHP Code:

$query = "INSERT INTO dagenstilbud SET(billede,tekst) VALUES='".$_FILES['filnavn']['name']."','$tekst'"; 



For an INSERT should be formed like so:
PHP Code:

$query = "INSERT INTO dagenstilbud(billede,tekst) VALUES('".$_FILES['filnavn']['name']."','$tekst')"; 


__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #3  
Old 21-Aug-2009, 05:40
dinno dinno is offline
New Member
 
Join Date: Aug 2009
Posts: 3
dinno is on a distinguished road

Re: image uploader


hey 1000 thanks, it works almost as it should, the upload the image to a folder and text from the entry fields in to the database but does not takes
the filename to the database ... how can it be?
dinno
  #4  
Old 21-Aug-2009, 05:45
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: image uploader


Good.

Sorry that I forgot to mention to also remove the = with the VALUES, but I had it correct in the example.

Anyway, echo the query string for output and make sure it looks like what is expected. Maybe the value is blank?
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #5  
Old 21-Aug-2009, 06:42
dinno dinno is offline
New Member
 
Join Date: Aug 2009
Posts: 3
dinno is on a distinguished road

Re: image uploader


Hello again have the right value was empty I did like this now and it works thanks smile again it looks like this now ...

<?php
if (isset($_FILES['filnavn'])) {print "Fil der er blevet overført: {$_FILES['filnavn']['name']}<p>\n";
$tekst=$_POST['tekst'];
$webadr=$_POST['webadresse'];
$userid=$_POST['userid'];
$filnavn=$_FILES['filnavn']['name'];
$query = "INSERT INTO dagenstilbud (billede, tekst, webadresse, mainid) VALUES ('$filnavn','$tekst','$webadr','$userid')";

$Result1 = mysql_query($query, $cms) or die(mysql_error());

}

{
$tempfile = $_FILES['filnavn']['tmp_name'];
$destination = "dagenstilbud/{$_FILES['filnavn']['name']}";
copy($tempfile, $destination);
}
?>
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image onto JFrame tedds Java Forum 8 25-Oct-2007 21:04
Importing images arety33 Java Forum 1 12-Jul-2007 14:28
draw in image jafar FLTK Forum 2 19-Sep-2006 11:51
GIM gidedit - a fltk fluid resize project cable_guy_67 FLTK Forum 2 01-Jun-2005 16:00
Checking source codes of image, audio and video files onauc C Programming Language 5 26-Feb-2005 22:47

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 12:19.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.