All pastes #912776 Raw Edit

Mine

public text v1 · immutable
·published 2008-02-21 17:00 UTC
rendered paste body
<?php 


$mysqli = new mysqli('host', 'user', 'pass', 'database'); 

/* check connection */ 
if (mysqli_connect_errno()) { 
    printf("Connect failed: %s\n", mysqli_connect_error()); 
    exit(); 
} 

$stmt = $mysqli->prepare("INSERT INTO NEWS VALUES (?, ?, ?)"); 
$stmt->bind_param('sss', $title, $text, $moretext); 

$title = 'this is the title'; 
$text = 'this is text'; 
$moretext = "some more text"; 

/* execute prepared statement */ 
$stmt->execute(); 


//WOULD THIS WORK?
$results = $stmt->fetch_object();

echo $results->TITLE;
//?

printf("%d Row inserted.\n", $stmt->affected_rows); 

/* close statement and connection */ 
$stmt->close(); 


$mysqli->close(); 
?>