$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
$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
是C API
[align=center]==== 思想重于技巧 ====
[/align]
[align=center]==== 思想重于技巧 ====
[/align]
<?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_insert_id() 返回上一步 INSERT 查询中产生的 AUTO_INCREMENT 的 ID 号。
如果上一查询没有产生 AUTO_INCREMENT 的值,则 mysql_insert_id() 返回 0
(PHP 3, PHP 4, PHP 5)mysql_insert_id -- 取得上一步 INSERT 操作产生的 ID