佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 728|回复: 4

php & mysql (update problem)

[复制链接]
发表于 27-8-2006 12:54 PM | 显示全部楼层 |阅读模式
when i click submit , it come out this error message

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in c:\program files\easyphp1-7\www\spm_projects\admin\update\memedit.php on line 12

why ???
here my coding
--------------------------------------------------------------------------
update.html

<html>

<head>

<title>New Page 1</title>
</head>

<body>

  
<form method=POST action=memedit.php>
<p>&nbsp;</p>
  <p>&nbsp; <font color="#009933">Book ID :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="text" name="T2" size="20"></font></p>
  <p>&nbsp;</p>
  <p><input type="submit" value="Submit" name="B1">&nbsp;&nbsp; <input type="reset" value="Reset" name="B2"></p>
</form>

</body>

</html>
--------------------------------------------------------------------------
memedit.php

<?php
       
        $aa="select * from book where bookID='$T2'";
        $bb=mysql_query($aa);
        list($T0,$D1,$T1,$T2,$T3,$T4,$T5,$T6,$T7,$T8) = mysql_fetch_row($bb);

echo "
<form method=POST action='memedit2.php'>
<p>&nbsp;</p>
  <p>&nbsp;<font color="#009933"> Category ID :</font> <select name="D1">
  <option value=1"; if ($D1==1) {echo " selected";} echo ">1
  <option value=2"; if ($D1==2) {echo " selected";} echo ">2
  <option value=3"; if ($D1==3) {echo " selected";} echo ">3
  <option value=4"; if ($D1==4) {echo " selected";} echo ">4
  <option value=5"; if ($D1==5) {echo " selected";} echo ">5
  <option value=6"; if ($D1==6) {echo " selected";} echo ">6
  <option value=7"; if ($D1==7) {echo " selected";} echo ">7
  <option value=8"; if ($D1==8) {echo " selected";} echo ">8
  </select></p>
  <p>&nbsp; <font color="#009933">Book ID :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  $T2</font></p>
  <p><font color="#009933">&nbsp; Book Name :&nbsp;
  <input type="text" name="T1" size="50" value=$T1></font></p>
  <p><font color="#009933">&nbsp; Author :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="text" name="T3" size="30" value=$T3></font></p>
  <p><font color="#009933">&nbsp; Publisher:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="text" name="T4" size="30" value=$T4></font></p>
  <p><font color="#009933">&nbsp; ISBN :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="text" name="T5" size="30" value=$T5></font></p>
  <p><font color="#009933">&nbsp; Price (RM) : </font>&nbsp;&nbsp;
  <input type="text" name="T6" size="30" value=$T6></p>
  <p>&nbsp;</p>
  <p><input type="submit" value="Update" name="B1">&nbsp;&nbsp; <input type="reset" value="Reset" name="B2"></p>
</form>

";
?>
--------------------------------------------------------------------------

memedit2.php

<?php
    mysql_connect("localhost","root","1234";
    mysql_select_db("book";
   
    $aa="
            update book set
            bookname='$T1',
            author='$T3',
            publisher='$T4',
            isbn='$T5',
            price='$T6',
    where bookid='$T2'
            ";
    mysql_query($aa);
   
    header("location:update.html";
    ?>
回复

使用道具 举报


ADVERTISEMENT

发表于 27-8-2006 06:28 PM | 显示全部楼层
不就是和你之前的问题一样吗??
回复

使用道具 举报

 楼主| 发表于 27-8-2006 06:32 PM | 显示全部楼层
又是 coding 大旧 ???
想不到以前所学的全部都 outdate leh  

[ 本帖最后由 html 于 27-8-2006 07:23 PM 编辑 ]
回复

使用道具 举报

发表于 27-8-2006 09:54 PM | 显示全部楼层
原帖由 html 于 27-8-2006 06:32 PM 发表
又是 coding 大旧 ???
想不到以前所学的全部都 outdate leh  

我以为你已经解决问题了~
@_@

你试下:

<?php
$D1=2;

echo "<select name='D1'><option value='1' "; if($D1==1) echo 'selected'; echo " >1</option>
<option value='2' "; if($D1==2) echo 'selected'; echo " >2</option>
<option value='3' "; if($D1==3) echo 'selected'; echo " >3</option></select>";
?>



上面只是个例子,可以的话用for loop来写~

<?php
$D1=5; $n=8;

echo "<select name='D1'>";

for($i=1; $i<=$n; $i++){
        echo "<option value=$n";
        if($D1==$i) echo ' selected';
        echo " >$i</option>";
        }
echo "</select>";
?>

[ 本帖最后由 亡者之疯 于 27-8-2006 10:14 PM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 27-8-2006 10:18 PM | 显示全部楼层
原帖由 亡者之疯 于 27-8-2006 09:54 PM 发表

我以为你已经解决问题了~
@_@

你试下:

<?php
$D1=2;

echo "<select name='D1'><option value='1' "; if($D1==1) echo 'selected'; echo " >1</option>
<o ...


我已经解决... i change it like below
--------------------------------------------------------------------------

<html>

<head>

<title>New Page 1</title>
</head>

<body>

<?php
        $link_id=mysql_connect("localhost", "root","1234");
    mysql_select_db("spm");
   
    $str="select bookid from book";
    $result=mysql_query($str,$link_id);
    $sn_index=mysql_num_rows($result);
    mysql_close($link_id);
   
    for($index=0;$index<$sn_index;$index++){
            $arr[$index]=mysql_fetch_array($result);
    };?>
                     
<?php
        if(isset($T1) and isset($T2) and isset($T3) and
           isset($T4) and isset($T5) and isset($T6)){
        $link_id = mysql_connect("localhost", "root","1234");
    mysql_select_db("spm");
   
    $str="
              update book set
              bookname='$T1',
              author='$T3',
              publisher='$T4',
              isbn='$T5',
              price='$T6'
              where bookid='$T2'";
             
           
    mysql_query($str,$link_id);
    mysql_close($link_id);
};
    ?>
   
   
    <form method=post action=tryup1.php>
    <p>&nbsp;<font color="#009933"> BookID :</font>
    <select name="T2">
    <?
            for($index=0;$index<$sn_index;$index++){
                    ?>
    <option><?echo $arr[$index]['bookid']?>  
    <?};?>
     </select>
  <p><font color="#009933">&nbsp; Book Name :&nbsp;
  <input type="text" name="T1" size="50"></font></p>
  <p><font color="#009933">&nbsp; Author :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="text" name="T3" size="30"></font></p>
  <p><font color="#009933">&nbsp; Publisher:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="text" name="T4" size="30"></font></p>
  <p><font color="#009933">&nbsp; ISBN :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="text" name="T5" size="30"></font></p>
  <p><font color="#009933">&nbsp; Price (RM) : </font>&nbsp;&nbsp;
  <input type="text" name="T6" size="30"></p>
  <p>&nbsp;</p>
  <p><input type="submit" value="Submit" name="B1">&nbsp;&nbsp; <input type="reset" value="Reset" name="B2"></p>
</form>

</body>

</html>
--------------------------------------------------------------------------
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 12-11-2024 06:04 AM , Processed in 0.112229 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表