Jump to content

Write SQL Query PHP Comform?


equipment

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.