Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.