Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Update recordset fails

LEGEND ,
Oct 19, 2006 Oct 19, 2006

Copy link to clipboard

Copied

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
TOPICS
Server side applications

Views

255
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 19, 2006 Oct 19, 2006

Copy link to clipboard

Copied

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/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 19, 2006 Oct 19, 2006

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 19, 2006 Oct 19, 2006

Copy link to clipboard

Copied

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/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 20, 2006 Oct 20, 2006

Copy link to clipboard

Copied

> 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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 20, 2006 Oct 20, 2006

Copy link to clipboard

Copied

LATEST
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/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines