This problem has plagued me for several days. The following figure shows how to jump to the query page after the data is submitted in the form, but it does not show that the inserted data database has been inserted, but if it is opened separately the Data Query page shows who can help me. below is my...
This problem has plagued me for several days. The following figure shows how to jump to the query page after the data is submitted in the form, but it does not show that the inserted data database has been inserted, but if it is opened separately the Data Query page shows who can help me?
The following is my code. You can try it. At first, I thought it was a cache problem. I used several browsers.
Submitted on the first page
The second page Inserts
$ 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 "script" alert ('published successfully'); location = 'cx2. php'; script ";
Mysql_close ($ con)
?>
The third page is queried. If this page is opened separately, the inserted data will be displayed, but the jump page will not be displayed, just as it is in the picture.
$ Con = mysql_connect ("localhost", "root ","");
If (! $ Con)
{
Echo "failed to connect to Database"; 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'
?>
Student IDNameAge
'. $ V ['id'].''; Echo''. $ V ['name'],''; Echo''. $ V ['num'].''; Echo'Edit';}
?>
Reply content:
This problem has plagued me for several days. The following figure shows how to jump to the query page after the data is submitted in the form, but it does not show that the inserted data database has been inserted, but if it is opened separately the Data Query page shows who can help me?
The following is my code. You can try it. At first, I thought it was a cache problem. I used several browsers.
Submitted on the first page
The second page Inserts
$ 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 "script" alert ('published successfully'); location = 'cx2. php'; script ";
Mysql_close ($ con)
?>
The third page is queried. If this page is opened separately, the inserted data will be displayed, but the jump page will not be displayed, just as it is in the picture.
$ Con = mysql_connect ("localhost", "root ","");
If (! $ Con)
{
Echo "failed to connect to Database"; 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'
?>
Student IDNameAge
'. $ V ['id'].''; Echo''. $ V ['name'],''; Echo''. $ V ['num'].''; Echo'Edit';}
?>
Use the header as the jump header ('location: xxx. php'). Check the error. It seems to be a version issue.
It should be a problem with your version. You can add @ before mysql_connect. I use your source code to test everything locally and there will be no error. However, this is not a positive solution. I suggest you upgrade the version or you can talk about the version of mysql you are using.