Page 1 of 1

add a value to a specific row in mysql

Posted: Tue May 12, 2009 2:05 am
by aneuryzma
How can I add a value to a specific row in mysql ?

The row is the one with that user_id value.

thanks

Code: Select all

if(isset( $_SESSION['user_id'] )) {
 
    try {
                        
                $db = mysqli_connect('127.0.0.1', 'root', 'mo98nf89') or die("Could not connect: " . mysqli_error());
                mysqli_select_db($db, "phpro_auth");
        
                $sql = 'INSERT INTO phpro_users (quote ) VALUES (?)';
        
                $stmt = $db->stmt_init( );
                   
                if ($stmt->prepare($sql)) {
        
                
                    // Associate placeholders with data type and variable name
                    $stmt->bind_param('s', $quote);
        
                
                    // Bind result variables
                    //$stmt->bind_result($username);
        
                    // Execute prepared statement
                    $stmt->execute( );
        
                }
 
            }

Re: add a value to a specific row in mysql

Posted: Tue May 12, 2009 3:44 am
by Yossarian
How can I add a value to a specific row in mysql ?
This is a question about your sql statement, to change a value in an existing row you use the UPDATE command instead,

Code: Select all

"update phpro_users set quote = 'et tu Brute?' where name = 'Caesar' ";