PHP I just inserted the code to show that the data can not be opened, but the page to open the query data to show that sorrow is dead

Source: Internet
Author: User

This question has been bothering me for a few days. The following image shows the data submitted in the form to jump to the query page but it does not appear to be inserted in the data database has been inserted but if you open the Data query page can be displayed who can help me?

Here's my code you guys can try it at first I thought it was a cache problem. Change a few browsers.
The first page submitted




The second page inserts a

$con =mysql_connect ("localhost", "root", "");; mysql_connect ("localhost", "root", "");
if (! $con)
{
Die (' Could not connect: '. Mysql_error ());
}
mysql_select_db ("T1", $con);
$sql = "INSERT into Stu (ID, name, num)
VALUES (' $_post[firstname] ', ' $_post[lastname] ', ' $_post[age] ') ";
if (!mysql_query ($sql, $con))
{

 die('Error: ' . mysql_error());

}
echo "";
Mysql_close ($con)
?>

The third page of the query, that is, this page if you open this page alone can display the data just inserted but jump over the page is not displayed like in the picture is really strange

$con = mysql_connect ("localhost", "root", "");
if (! $con)
{

 echo "连接数据库失败"; exit;

}
$sql = ' Use T1 ';
mysql_query ($sql, $con);
$sql = ' Select*from stu ';
$rs =mysql_query ($sql, $con);
$list =array ();
while ($row =mysql_fetch_assoc ($rs)) {

$list[]=$row;

}
Echo ' $sql '
?>





    • 学号
    • 姓名
    • 年龄

      
         
          '.$v['id'].'';  echo '
    • '.$v['name'],'
    • '; echo '
    • '.$v['num'].'
    • '; echo '
    • 编辑
    • ';}

      ?>



Reply content:

This question has been bothering me for a few days. The following image shows the data submitted in the form to jump to the query page but it does not appear to be inserted in the data database has been inserted but if you open the Data query page can be displayed who can help me?

Here's my code you guys can try it at first I thought it was a cache problem. Change a few browsers.
The first page submitted




The second page inserts a

$con =mysql_connect ("localhost", "root", "");; mysql_connect ("localhost", "root", "");
if (! $con)
{
Die (' Could not connect: '. Mysql_error ());
}
mysql_select_db ("T1", $con);
$sql = "INSERT into Stu (ID, name, num)
VALUES (' $_post[firstname] ', ' $_post[lastname] ', ' $_post[age] ') ";
if (!mysql_query ($sql, $con))
{

 die('Error: ' . mysql_error());

}
echo "";
Mysql_close ($con)
?>

The third page of the query, that is, this page if you open this page alone can display the data just inserted but jump over the page is not displayed like in the picture is really strange

$con = mysql_connect ("localhost", "root", "");
if (! $con)
{

 echo "连接数据库失败"; exit;

}
$sql = ' Use T1 ';
mysql_query ($sql, $con);
$sql = ' Select*from stu ';
$rs =mysql_query ($sql, $con);
$list =array ();
while ($row =mysql_fetch_assoc ($rs)) {

$list[]=$row;

}
Echo ' $sql '
?>





    • 学号
    • 姓名
    • 年龄

      
         
          '.$v['id'].'';  echo '
    • '.$v['name'],'
    • '; echo '
    • '.$v['num'].'
    • '; echo '
    • 编辑
    • ';}

      ?>



Use the header to do the jump header (' Location:xxx.php '), see the error, as if the version of the problem

Should be your version of the problem, you can add in front of the mysql_connect @, I use your source, in the local test everything is normal and will not prompt the wrong. But this is not a positive approach, I suggest you upgrade the version, you can also tell me which version of MySQL you are using.


  
   
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.