PHP+SQL Need help
I want get ID which have autoincrement value and save to variable because i want sue it in next table.
I dont knwo why it dont work and result is every time 0 or unknown value I tried it rework 150x nothing works i really dont knwo where is problem :( Im parsig variables here: Code:
$url = filter_input_array( INPUT_GET ); Code:
$result = @mysql_query( "INSERT INTO `".$mysql_prefix."sms_keys` (`sms_text`, `sms_credit`, `sms_real_credit`, `sms_time`, `sms_id`, `sms_customer_text`, `sms_custom_nick`, `sms_custom_steamid`, `sms_custom_password`, `sms_refip`) VALUES ('".mysql_real_escape_string( $url['sms'] )."', '".mysql_real_escape_string( $url['credit'] )."', '".mysql_real_escape_string( $url['real_credit'] )."', '".$url['time']."', '".$url['id']."', '".mysql_real_escape_string( $url['customer_text'] )."', '".mysql_real_escape_string( $url['custom_NICK'] )."', '".mysql_real_escape_string( $url['custom_STEAMID'] )."', '".mysql_real_escape_string( $url['custom_PASSWORD'] )."', '".mysql_real_escape_string( $url['refip'] )."')" ) or die (mysql_error()); Code:
$id = (int) $row['id']; Code:
Resource id #9 This works for me in phpmyadmin SQL it return good value in this example 67 Code:
SELECT `id` FROM `amx_amxadmins` WHERE (`username`, `password`, `access`, `flags`, `steamid`, `nickname`, `ashow`, `days`) = ("HODNOTA", "HODNOTA", "bnopqrstz", "a", "HODNOTA", "HODNOTA", "0", "30"); |
Re: PHP+SQL Need help
mysql_query (and related mysql_ functions) have been deprecated, and won't be there in PHP 7+, so you might want to switch it out to either MySQLi or PDO, to ensure compatibility, in the event that you should ever decide to come out of the stone age.
To grab the "new" ID from auto increment rows, you can use the following: MySQLi: mixed $mysqli->insert_id; PDO: public string PDO::lastInsertId ([ string $name = NULL ] ) Legacy stone age functions: int mysql_insert_id ([ resource $link_identifier = NULL ] ) |
Re: PHP+SQL Need help
Thank you really much! 8 hours i tried to solve... :D
|
All times are GMT -4. The time now is 07:21. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.