Jump to content

[SOLVED] not updating database


blui

Recommended Posts

Hi all, still trying to get my head round this php coding, hoping someone can help.

I current have a form which creates 5 links from drop down menus and a second page which updates the database with the new values. I have managed to get it working with 1 value but for some reason, it will only update teh last value not all 5 of them. Can anyone see were I'm going wrong? all help is greatly appreciated. my code is shown below:-

 

phpinfo.php

<form action="../php/postinfo2.php" method="post">

  <label>Choose your image for 1

  <select name="imagelist">

<?

require('directorylistinginc.php');

?>

  </select>

  </label>

  <br />

  <label>Choose your image for 2

  <select name="imagelist2">

<?

require('directorylistinginc.php');

?>

  </select>

  </label>

  <label><br />

  Choose your image for 3

  <select name="imagelist3">

<?

require('directorylistinginc.php');

?>

  </select>

  </label>

  <br />

  <label>Choose your image for 4

  <select name="imagelist4">

<?

require('directorylistinginc.php');

?>

  </select>

  </label>

  <br />

  <label>Choose your image for 5

  <select name="imagelist5">

<?

require('directorylistinginc.php');

?>

  </select>

  </label>

  <input type="submit" name="submit" value="submit"> 

</form>

 

-----------------------------------------------------------------

 

phpinfo2.php

<?

require_once('connectionlocal.php');

?>

<?PHP

//inserts image link into approprate cell

$sql = "UPDATE `cmscontent` SET `links1` = '$_POST[imagelist]' WHERE `PRIMARYID`=1  ";

$sql = "UPDATE `cmscontent` SET `links1` = '$_POST[imagelist2]' WHERE `PRIMARYID`=2  ";

$sql = "UPDATE `cmscontent` SET `links1` = '$_POST[imagelist3]' WHERE `PRIMARYID`=3  ";

$sql = "UPDATE `cmscontent` SET `links1` = '$_POST[imagelist4]' WHERE `PRIMARYID`=4  ";

$sql = "UPDATE `cmscontent` SET `links1` = '$_POST[imagelist5]' WHERE `PRIMARYID`=5  ";

$queryResult = mysql_query($sql)

    or die("An error has happened: " . mysql_error());

?>

<?php

// Change to the URL you want to redirect to

$URL="http://pauldaleragu/php/postinfo.php";

header ("Location: $URL");

?>

Link to comment
https://forums.phpfreaks.com/topic/44210-solved-not-updating-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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