1

I am simply trying to insert the variable from a session into a MySQL database and it causes it to fail. var_dump shows SESSIONS all there. No problem there. Why doesn't this work?

$job = $_SESSION['job'];

$user_id = '1';
$name = 'allie';

$stmt = $mysqli->prepare("INSERT INTO
                        requests(name,job_info,user_id) 
                        VALUES (?,?,?)");

$stmt->bind_param('sss', $name, $job, $user_id);
$stmt->execute();   
ByteHamster
  • 4,884
  • 9
  • 38
  • 53
looloobs
  • 761
  • 2
  • 11
  • 24

1 Answers1

1

see pdo bind_param

your parameter is incorrect: change this:

$stmt->bind_param('sss', $name, $job, $user_id);

with this:

$stmt->bind_param(1, $name, PDO::PARAM_STR);
$stmt->bind_param(2, $job, PDO::PARAM_STR);
$stmt->bind_param(3, intval($user_id), PDO::PARAM_INT);
Ari Djemana
  • 1,229
  • 12
  • 12