读书人

关于mysql_insert_id的有关问题

发布时间: 2012-02-09 18:22:27 作者: rapoo

关于mysql_insert_id的问题
$lastid=mysql_insert_id();
$query="insert into 'mywesite'.'word'('id','word') values('".$lastid."','".$word."')";
这样是不是不对?
一直这样说:
Warning: mysql_insert_id() [function.mysql-insert-id]: A link to the server could not be established in F:\xampp\htdocs\my website\add_url.php on line 50


[解决办法]

PHP code
<?php    mysql_connect("localhost", "mysql_user", "mysql_password") or        die("Could not connect: " . mysql_error());    mysql_select_db("mydb");    mysql_query("INSERT INTO mytable (product) values ('kossu')");    printf ("Last inserted record has id %d\n", mysql_insert_id());?> 

读书人网 >Mysql

热点推荐