Jump to content

Inserting INTO


cdoggg94

Recommended Posts

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

post-110186-13482403637915_thumb.jpg

Link to comment
Share on other sites

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

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.