lwaters;11022441 wrote:Well, I am a newbie and using Dreamweaver and unfortunately I am in a time crunch and I don't know mysqli yet. 🙁
What a wonderful opportunity to Learn! 🙂
mysqli has a procedural interface that closely mirrors the old mysql functions.
While the object-oriented API is much more natural and fluid, the procedural functions have a more gradual learning curve - choose for yourself.
An example:
<?php
## procedural example ##
// create a database connection using mysqli
$DB = mysqli_connect( 'databaseHost','username','password','databaseName' );
// sanitize the user-supplied data
$sanitized_POST_param = mysqli_real_escape_string( $DB,$_POST['param'] );
// query
$SQL = "SELECT `column` FROM `table` WHERE `column`='$sanitized_POST_param'";
// execute query
$result = mysqli_query( $DB,$SQL );
// check for result
if( $result !== false ){
// loop through results
while( $row = mysqli_fetch_assoc( $result ) ){
/* do whatever */
}
// close result
mysqli_free_result( $result );
}
## same example, object-oriented style ##
// create a database connection using mysqli
$DB = new mysqli( 'databaseHost','username','password','databaseName' );
// sanitize the user-supplied data
$sanitized_POST_param = $DB->real_escape_string( $_POST['param'] );
// query
$SQL = "SELECT `column` FROM `table` WHERE `column`='$sanitized_POST_param'";
// execute query
$result = $DB->query( $SQL );
// check for result
if( $result !== false ){
// loop through results
while( $row = $result->fetch_assoc() ){
/* do whatever */
}
// close the result
$result->close();
}