Version: , by TECK
Developer Last Online: Nov 2023
Version: Unknown
Rating:
Released: 02-20-2002
Last Update: Never
Installs: 0
No support by the author.
i want to call in settinggroup the last settinggroupid (for example, 32 that i just created in settinggroup with a NULL). here what i came up with:
PHP Code:
$settinggroupid=$DB_site->query("SELECT LAST_INSERT_ID() FROM settinggroup");
$DB_site->query("INSERT INTO setting VALUES (NULL,$settinggroupid,'News forum ID','newsforumid','15','The specified forum will contain threads viewed on the main page only.','',0)");
it doesnt want to grab it... hmmmm.. i'm upset :noid:
the script returns this:
---------------------------------------
INSERT INTO setting VALUES (NULL,Resource id #6,'News forum ID','newsforumid','15','The specified forum will contain threads viewed on the main page only.','',0)
instead of:
---------------------------------------
INSERT INTO setting VALUES (NULL,32,'News forum ID','newsforumid','15','The specified forum will contain threads viewed on the main page only.','',0)
$settinggroupid=$DB_site->query_first("SELECT LAST_INSERT_ID() FROM settinggroup");
$DB_site->query("INSERT INTO setting VALUES (NULL,$settinggroupid,'News forum ID','newsforumid','15','The specified forum will contain threads viewed on the main page only.','',0)");
echo "Adding setting data... Done. <font color='#006699'>setting</font> table populated.<p></td>\n";
i need to call the last ID from settinggroup and insert it as a value into setting. let me know where i do it wrong.
Yes it returns an array, thats how you get data from the database, or you fetch row or fetch object.
use $settinggroupid[LAST_INSERT_ID()] as you said its an array. If your ever curious to what value an array holds you can use print_r($array);
and it will print out all the values of $array.
Anyway you can use $DB_site->insert_id(); to use the abstraction layer if you want.
its part of the abstraction layer which simply uses mysql_insert_id(); which is a nice trait of mysql as it gets the last value of the auto incrememnt column.
The bit of code you posted is correct nakkid.
mysql_insert_id() returns the last auto-increment ID that was insert into the DATABASE during the current connection.
$settinggroupid=$DB_site->insert_id();
$DB_site->query("INSERT INTO setting VALUES (NULL,$settinggroupid,'News forum ID','newsforumid','15','The specified forum will contain threads viewed on the main page only.','',0)");
echo "Adding setting data... Done. <font color='#006699'>setting</font> table populated.<p></td>\n";
thanks alot PPN... i posted a thread in Website Feedback. let me know if i'm crazy.. read more in my signature why i decide not to post any hacks anymore here.
however, i will give you a copy of the script once completed, so you can use it. i will keep in touch here through pm's and email.
thanks alot for all your support (scott and chen).