Skip to main content
Inspiring
October 19, 2006
Question

Update recordset fails

  • October 19, 2006
  • 5 replies
  • 283 views
Hello,

I have a form to upload images and to insert names and paths into a
database. The images are really uploaded, but the database update
doesn't work. The code is:

mysql_select_db("books");
$sql = "INSERT INTO filestore SET
main_pic1orig='hauptpics/$image_stored',
main_pic1small='hauptpics/$img_name'";
$action = mysql_query($sql);
$sql = "UPDATE hauptliste SET
main_pic1orig='hauptpics/$_POST[main_pic1orig].jpg',
main_pic1small='hauptpics/$_POST[main_pic1small].jpg',
WHERE main_id='$_GET[main_id]'";
$action = mysql_query($sql);
echo "<p><b>Added files:</b></p>";
echo "<p>Original: ".$image_stored."</p>";
echo "<p>Thumbnail: ".$img_name."</p>";

Is there something wrong with that code?

Martin
This topic has been closed for replies.

5 replies

Inspiring
October 20, 2006
Martin Lang wrote:
> I've changed the name of the database table, so bookstore became
> filestore. Now it works.

We've all done that - probably more often than we'd like to admit. ;)

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Inspiring
October 20, 2006
> David Powers wrote:
> So where are these values meant to come from? There is no mention of
> them in your previous code.

Shame - I've changed the name of the database table, so bookstore became
filestore. Now it works.
Sorry :(

Martin
Inspiring
October 19, 2006
Martin Lang wrote:
> I've inserted that:
>
> echo $row_rshaupt['main_pic1orig'];
> echo $row_rshaupt['main_pic1small'];
>
> Nothing is displayed.

So where are these values meant to come from? There is no mention of
them in your previous code.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Inspiring
October 19, 2006
David Powers wrote:
> Use echo to display the value of the $sql variables to make sure that
> you're getting the values you expect.

I've inserted that:

echo $row_rshaupt['main_pic1orig'];
echo $row_rshaupt['main_pic1small'];

Nothing is displayed. So there is something broken. In the master page
there is a link to the page "insert images". If it is record #5, the
upload page inserts two images, 5.jpg for the original image, 5k.jpg for
the thumbnail. The corresponding fields in the form are:

<input type="hidden" name="main_id" value="<?php echo $_GET['main_id']; ?>">
<input name="main_pic1orig" type="text" id= main_pic1orig" value="<?php
echo $_GET['main_id']; ?>" size="25" maxlength="25"></td></tr>
<input name="main_pic1small" type="text" id="main_pic1small"
value="<?php echo $_GET['main_id']; ?>k" size="25" maxlength="25">

As I said the folder contains the two images, but not the database. I
simply don't see the error. Any ideas?

Martin

Inspiring
October 19, 2006
Martin Lang wrote:
> Is there something wrong with that code?

Use echo to display the value of the $sql variables to make sure that
you're getting the values you expect.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/