cdoggg94 Posted July 26, 2012 Share Posted July 26, 2012 So I have gotten this exact same thing to work many times... today it does not want to upload... I have narrowed it down to the part but everything seems to be correct...I have looked over it several times and cant seem to find out what is going on.. here is the full upload code: <?php error_reporting(0); mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("my_db") or die(mysql_error()); $picture = $_FILES['image']['tmp_name']; $title = $_POST['title']; $info = $_POST['info']; $period = $_POST['period']; //echo $period; $link = "<a href='http://www.MYSITE.com/Agency/product3.php?Product=".$_POST['proNumber']."' target='_blank'>Details</a>"; if(!isset($picture)) echo ""; else { $image = addslashes(file_get_contents($_FILES['image']['tmp_name'])); $image_name = addslashes($_FILES['image']['name']); $image_size = getimagesize($_FILES['image']['tmp_name']); $max_width = 250; $max_height = 377; list($width, $height) = $image_size; //echo $width.",".$height; $ratioh = $max_height/$height; $ratiow = $max_width/$width; $ratio = min($ratioh, $ratiow); // New dimensions $mywidth = intval($ratio*$width); $myheight = intval($ratio*$height); //echo $mywidth." x ".$myheight ; if($image_size==FALSE) echo "No image was seleted"; else{ if(!$insert = mysql_query ("INSERT INTO LTO_tbl VALUES ('','".$image_name."','".$image."','".$title."','".$info."','".$myheight."','".$mywidth."','".$period."','".$link."')")) echo "Problem Uploading Image."; else{ $lastid = mysql_insert_id(); //$lastid = "23"; echo "LTO added!<p /> This is what will appear on your page:<p /> <table border='0'> <tr> <td valign='top'><img src='get_3.php?Product=$lastid' height='".$myheight."' width='".$mywidth."' ></td> <td valign='top'> Title: ".$title." <p> LTO Info: ".$info."</p> <p> Link: ".$link."</p> <p> Period: ".$period."</p> </td> </tr> </table> "; } } } ?> and this would be the form : <form action="newLTO.php" method="post" enctype="multipart/form-data"> <table width="600" border="0" > <tr> <td align="right">Image:</td> <td><input style="background-color:#000" type="file" name="image"></td> </tr> <tr> <td align="right">Title:</td> <td><input style="background-color:#000; color:#FFF;" name="title" type="text"/></td> </tr> <tr> <td align="right">LTO Info:</td> <td><textarea name="info" cols="40" rows="10" style="background-color:#000; color:#FFF;"></textarea></td> </tr> <tr> <tr> <td align="right">Product Number:</td> <td><input name="proNumber" type="text" style="background-color:#000; color:#FFF;" /></td> </tr> <tr> <td align="right">Period:</td> <td><input name="period" type="text" style="background-color:#000; color:#FFF;" /></td> </tr> <tr> <td align="right"></td> <td><input INPUT TYPE="image" SRC="images/images/addLTO.jpg" HEIGHT="31" WIDTH="50" BORDER="0" ALT="Submit Form" /> </td> </tr> </table> </form> i have attached an image on the DB Im not asking someone to do it for me but if anyone could maybe give me some advice as to what im doing wrong it would be greatly appreciated.. Quote Link to comment https://forums.phpfreaks.com/topic/266287-inserting-into/ Share on other sites More sharing options...
Pikachu2000 Posted July 26, 2012 Share Posted July 26, 2012 You're having problems with a script, but you've intentionally shut off error reporting. That makes no sense at all. Change it to error_reporting(-1) and see if you get some clues. Quote Link to comment https://forums.phpfreaks.com/topic/266287-inserting-into/#findComment-1364591 Share on other sites More sharing options...
cdoggg94 Posted July 26, 2012 Author Share Posted July 26, 2012 Nothing comes up when turned to (-1) I just get the error I have put in saying "Problem Uploading Image" ..reading my last post I left out the part that I'm sure is causing the issue... this part: if(!$insert = mysql_query ("INSERT INTO LTO_tbl VALUES ('','".$image_name."','".$image."','".$title."','".$info."','".$myheight."','".$mywidth."','".$period."','".$link."')")) echo "Problem Uploading Image."; I have echoed information up until that point and everything worked till right there Quote Link to comment https://forums.phpfreaks.com/topic/266287-inserting-into/#findComment-1364596 Share on other sites More sharing options...
Jessica Posted July 26, 2012 Share Posted July 26, 2012 Look at mysql_query and mysql_error And quit concatenating strings when you don't need to, thats a PITA to read. Lastly, use the syntax INSERT INTO table(column, column) VALUES(value, value). Quote Link to comment https://forums.phpfreaks.com/topic/266287-inserting-into/#findComment-1364598 Share on other sites More sharing options...
cdoggg94 Posted July 26, 2012 Author Share Posted July 26, 2012 is there a reason that it would show the percentage uploading in the bottom of the broswer if it doesn'y actually upload it ? Quote Link to comment https://forums.phpfreaks.com/topic/266287-inserting-into/#findComment-1364609 Share on other sites More sharing options...
cdoggg94 Posted July 26, 2012 Author Share Posted July 26, 2012 Turned out that it works if the $link variable doesn't have the "<a href...etc." in it and only the $_POST information then it works fine... Quote Link to comment https://forums.phpfreaks.com/topic/266287-inserting-into/#findComment-1364629 Share on other sites More sharing options...
cdoggg94 Posted July 26, 2012 Author Share Posted July 26, 2012 as you said.. Quote Link to comment https://forums.phpfreaks.com/topic/266287-inserting-into/#findComment-1364631 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.