GRooVeZ Posted April 6, 2012 Share Posted April 6, 2012 i want the name of a picture stored in my db after i upload it the data is not stored in the db after i run this script, but i dont get errors either i print the two vars before sending them, and they get printed fine any help on this would be greatly appreciated thanks ! <?php error_reporting(E_ALL); ini_set("display_errors", 1); // INCLUDE THE CLASS FILE include('ImageLib.Class.php'); include("./includes/egl_inc.php"); $displayMessage = ''; if($_POST){ if(isset($_FILES['image_file'])){ // SEE THE MAGIC HAPPEN $destination_path = 'uploads/'; $post_file_name = 'image_file'; $width = 600; $height = 400; $scale = false; $trim = true; $uniqueName = true; $img = ImageLib::getInstance()->upload($post_file_name, $destination_path, $uniqueName)->resize($width, $height, $scale, $trim)->save(); $imgstr = mysql_real_escape_string ($img); $fileName = $_FILES['image_file']['name']; $displayMessage = '<div class="image"><img src="'.$destination_path.$fileName.'" /><br />Uploaded And Resized...With new file name : "'.$img.'"</div><br /><br />'; $playerid=$_SESSION['tid']; $matchdetails = mysql_fetch_array(mysql_query("SELECT id FROM ffa_matches WHERE status=2 and admin=$playerid")); $id = $matchdetails[id]; print $img;print $imgstr; print $id; mysql_query(" INSERT INTO ffa_screens (imgname,match) VALUES( '" . mysql_real_escape_string($imgstr) . "', '" . mysql_real_escape_string($id) . "' )"); }} ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>ImageLib Samples By Rahul Kate</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style> body{font-family: arial; font-size:12px; color:#444444; padding:20px;} li{margin-top:10px;} .image{color:green;} .image img{margin-bottom:5px;} </style> </head> <body> <h1>ImageLib | Upload Image, move it to Uploads folder and Resize it and Trim</h1> <?php echo $displayMessage; ?> <form method="post" enctype="multipart/form-data"> Select Image<br /> <input type="file" name="image_file" id="image_file" /> <br /> <br /> <input type="submit" name="submit" value="Submit" /> <br /> <br /> <a href="index.html">Back TO Home</a> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/260477-no-data-stored-after-a-insert-query/ Share on other sites More sharing options...
samshel Posted April 6, 2012 Share Posted April 6, 2012 $strSql = " INSERT INTO ffa_screens (imgname,match) VALUES( '" . mysql_real_escape_string($imgstr) . "', '" . mysql_real_escape_string($id) . "' )"; echo $strSql; $result = mysql_query($strSql) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/260477-no-data-stored-after-a-insert-query/#findComment-1335076 Share on other sites More sharing options...
GRooVeZ Posted April 6, 2012 Author Share Posted April 6, 2012 $strSql = " INSERT INTO ffa_screens (imgname,match) VALUES( '" . mysql_real_escape_string($imgstr) . "', '" . mysql_real_escape_string($id) . "' )"; echo $strSql; $result = mysql_query($strSql) or die(mysql_error()); 4f7f567cb7641.jpg4f7f567cb7641.jpg66 INSERT INTO ffa_screens (imgname,match) VALUES( '4f7f567cb7641.jpg', '66' )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 'match) VALUES( '4f7f567cb7641.jpg', '66' )' at line 2 Quote Link to comment https://forums.phpfreaks.com/topic/260477-no-data-stored-after-a-insert-query/#findComment-1335082 Share on other sites More sharing options...
Psycho Posted April 6, 2012 Share Posted April 6, 2012 Match is a reserved word in MySQL. Either change the field name or use backticks around the field name in your queries: `match` Quote Link to comment https://forums.phpfreaks.com/topic/260477-no-data-stored-after-a-insert-query/#findComment-1335084 Share on other sites More sharing options...
GRooVeZ Posted April 6, 2012 Author Share Posted April 6, 2012 yeah man ! nice thx ! Quote Link to comment https://forums.phpfreaks.com/topic/260477-no-data-stored-after-a-insert-query/#findComment-1335091 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.