Jump to content

[SOLVED] script won't post to mysql


andr923

Recommended Posts

	$connect = new connector();
$caption = $_POST['caption'];
$caption = htmlentities($caption);
$img = $_POST['img'];
$by = $_POST['by'];
$by = htmlentities($by);

$insertQuery = "INSERT INTO gallery (img, caption, by) VALUES ('$img','$caption','$by')";
	if ($connect->query($insertQuery)){
		echo "<center><h4>pic added</h4></center>";
		}else{
		echo "<center><h4>pic did not get added</h4></center>";
		}
	$connect->close();

 

That is the code I'm using to try and post the image information into my gallery's database.  I mostly copied the code exactly from a similar script I use for my blog table but for some reason this won always fails to insert the query and gives me the "did not get added" message. 

 

This is the code for the form that submits the information:

 

<form name="form1" method="post" action="postpic.php">
<p>
<input name="img" type="text" value="filename (without .jpg)" size="30">
</p>
<p>
<input name="by" type="text" value="by" size="30">
</p>
<p><br>
<textarea name="caption" cols="40" rows="10">caption</textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>

 

I know it's gotta be a small thing 'cause this works for my blog script.

Link to comment
Share on other sites

I changed all the instances of 'img' or '$img' to 'pic' and '$pic' and all the instances of 'by' and '$by' to 'author' and '$author' and I guess now it works.  So i guess maybe one of those variables is reserved by either the php or mysql system?

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.