equipment Posted April 21, 2012 Share Posted April 21, 2012 This is something I put together, I would like to know, how does it have to be rewritten to be PHP comform? # The Insertion Into the Database $db_connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $sql_query = sprintf( "set @newid = convert( ( select max(convert( (substring(tag_id, 2)) , unsigned integer))+1 from tags), char(10) ); set @newid = if(length(@newid) = 1, concat('0', @newid), @newid); set @newid = concat('c', @newid); INSERT INTO tags (tag_id, tag_name, tag_description, added_by_user_id, creation_date, last_edited) VALUES (@newid, '%s', '%s', 7, now(), '0')", mysqli_real_escape_string($db_connect, $tag_name), mysqli_real_escape_string($db_connect, $tag_description) ); $sql_query_run = mysqli_query($db_connect, $sql_query); As of yet I could execute the script and would not get error messages, though also no data would be entered into the table. Link to comment https://forums.phpfreaks.com/topic/261352-write-sql-query-php-comform/ Share on other sites More sharing options...
requinix Posted April 21, 2012 Share Posted April 21, 2012 If by "PHP comform" you mean "work", then mysqli_query() can't run multiple queries. Luckily mysqli_multi_query can. Link to comment https://forums.phpfreaks.com/topic/261352-write-sql-query-php-comform/#findComment-1339253 Share on other sites More sharing options...
equipment Posted April 21, 2012 Author Share Posted April 21, 2012 Thanks a lot, worked like a charm. It can be that easy as well. Link to comment https://forums.phpfreaks.com/topic/261352-write-sql-query-php-comform/#findComment-1339261 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.