Cainiao asks for help to obtain the value from the front-end form. in the input database, PHPcode $ dbmysql_connect (localhost, root, news1); $ query & quot; insertintonews (title, author, datetime, content) values ($ title, $ author, $ datetime, $ c Cainiao seek help from the foreground form to get the value from the input database
PHP code
$db=mysql_connect('localhost','root','','news1');$query="insert into news (title,author,datetime,content)values('$title','$author','$datetime','$content')"; $result=mysql_query($query);if($result){ echo mysql_affected_rows()."row(s) insert into database.";}else{ echo "An error has occurred.The item was not added.";}
After The related values are input, The output result is always An error has occurred. The item was not added. why should I modify it?
Thank you ~
------ Solution --------------------
Mysql_connect ('localhost', 'root ','');
Mysql_select_db ('news1 ')
------ Solution --------------------
If the mysql_connect and mysqli_connect parameters are used differently, the database cannot be specified.
Look at the manual,
------ Solution --------------------
$ Db = mysql_connect ('localhost', 'root', '') or die ('database connection to server failed ');
Mysql_select_db ('news1', $ db) or die ('database connection failed ');
........
------ Solution --------------------
$ Query = "insert into news (title, author, datetime, content) values ('$ title',' $ author', '$ datetime', '$ content ') or die (mysql_error ())";
See what is prompted.
------ Solution --------------------
This problem... Immediately output SQL...