Reply to Re: what is wrong with my PHP script for MySQL updating?

Your name:

Reply:


Posted by Schraalhans Keukenmeester on 04/02/07 11:40

Siong.Ong@gmail.com wrote:
> Dear all,
> my PHP aims to update a MySQL database by selecting record
> one by one and modify then save.
>
> Here are my PHP, but I found that it doesnt work as it supposed to be,
> for example, when Record (i) is shown and modified, the change will
> come to Record (i+1).
>
> Can anyone provide suggestion?
> thanks.
>
>
> <?php
> $connect = mysql_connect("andy","kiong","Password")or
> die("Could not connect : " . mysql_error()); ;
> mysql_select_db("kiong_userinfo",$connect)or die("Could not
> connect : " . mysql_error());
> $result = mysql_query("SELECT * FROM putonServer where id2=1",
> $connect);
> printf("%s<br>\n", mysql_result($result,0,"body"));
>
>
>
> ?>
> <table width="556" height="70" border="0"
> align="center">
> <tr>
> <td width="59" height="66">&nbsp;</td>
> </tr>
> </table>
> <p align="center">
> <?php
>
> $this_id=mysql_result($result,0,"id");
> $next_id=$this_id+1;
> $cat=mysql_result($result,0,"category");
> $newline = "<br />";
>
> if($cat==1)
> {
> echo "Process".$newline;
> echo $newline;
> }elseif($cat==2)
> {
> echo "Product".$newline;
> echo $newline;
> }else{
> echo "People".$newline;
> echo $newline;
> }
>
> $ori=mysql_result($result,0,"orientation");
>
> echo "$ori";
>
> ?>
>
> <?php
> $connect = mysql_connect("Server","kiong","Password")or
> die("Could not connect : " . mysql_error());
> $db_selected = mysql_select_db("kiong_userinfo",
> $connect);
> if (!$db_selected) {
> die ('Can\'t use foo : ' . mysql_error());
> }
> if($_POST[B2]){
> $query_B2 ="UPDATE putonServer SET
> category='$_POST[R2]',orientation='$_POST[sliderinput22]' where
> id='$this_id'";
> echo $this_id.$newline;
> $result_B2=mysql_query($query_B2,$connect);
> if (!$result_B2) {
> die ('Puke, Wrong2 ' . mysql_error());
> }
> $query_B2_1="update putonServer SET id2=4 where
> id='$this_id'";
> echo $this_id.$newline;
> $query_B2_2="update putonServer SET id2=1 where
> id='$next_id'";
> echo $this_id.$newline;
> $result_B2_2=mysql_query($query_B2_2,$connect);
> if (!$result_B2_2) {
> die ('Puke, Wrong ' . mysql_error());
> }
> $result_B2_1=mysql_query($query_B2_1,$connect);
> if (!$result_B2_1) {
> die ('Puke, Wrong2 ' . mysql_error());
> }
>
> }elseif($_POST[B0]){
> $query_B0="update putonServer SET id2=7 where id='$this_id'";
> $query_B0_2="update putonServer SET id2=1 where
> id='$next_id'";
>
> $result_B0=mysql_query($query_B0,$connect);
> if (!$result_B0) {
> die ('Puke, Wrong2 ' . mysql_error());
> }
> $result_B0_2=mysql_query($query_B0_2,$connect);
> if (!$result_B0_2) {
> die ('Puke, Wrong ' . mysql_error());
> }
>
> }elseif($_POST[B1]){
>
> $query_B1="update putonServer SET id2=0 where id='$this_id'";
> $query_B1_2="update putonServer SET id2=1 where
> id='$next_id'";
>
> $result_B1=mysql_query($query_B1,$connect);
> if (!$result_B1) {
> die ('Puke, Wrong2 ' . mysql_error());
> }
> $result_B1_2=mysql_query($query_B1_2,$connect);
> if (!$result_B1_2) {
> die ('Puke, Wrong ' . mysql_error());
> }
> }
> ?>
>
You make a db conection twice, do I see correctly these are two separate
scripts you posted here? If so, where does the second get the values for
$this_id etc? They are set in the first script, I can't see if/how they
are parsed to the second one.

Besides, it's quite hard to tell what is going on in the scripts. No
documentation whatsoever and some cryptic variables/values here and
there. Tough to decipher.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация