Good day guys, having some issues getting the following to work:
<?php
$db = new PDO('sqlite:test22.db');
function insertMember($db, $firstname, $sname ){
$sql = sprintf("INSERT INTO info (name, surname) VALUES ( "%s", '%s' '%s')");
echo $sql . '<br/>';
$db->query($sql);
}
$firstname = array(
'Johnathon',
'Anthony',
'Erasmo',
'Raleigh',
'Nancie',
'Tama',
'Camellia',
'Augustine',
);
$lastname = array(
'Mischke',
'Serna',
'Pingree',
'Mcnaught',
'Pepper',
'Schildgen',
'Mongold',
'Wrona',
'Geddes',
'Lanz',
);
$name = $firstname[rand ( 0 , count($firstname) -1)];
$name .= ' ';
$surname = $lastname[rand ( 0 , count($lastname) -1)];
insertMember($db, $name, $surname);
;
?>
The video tutorial I followed made use of "%s" but for some reason my browser tells me the syntax is incorrect. I am a bit lost, as I am relatively new to PHP as a whole.
Any assistance would be appreciated.
Cheers!