Insert numbers before variable

Asked

Viewed 27 times

1

I want to insert the variable phone with the 351 before the variable, I’m trying this way:

$query = 'INSERT INTO raddb.Utente (telefone) VALUES ( ?)';
$stmt = $conn->prepare( $query );
$stmt->bind_param("s", 351$telefone);
$stmt->execute();

But this way does not insert. I also tried so:

$query = 'INSERT INTO raddb.Utente (telefone) VALUES ( 351?)';
$stmt = $conn->prepare( $query );
$stmt->bind_param("s", $telefone);
$stmt->execute();

But also without success

  • Why not concatenate the variable? eg: '351'.$telefone

1 answer

4


Need to concatenate with the . as follows, ($telefone = '351'.$telefone;), example:

$telefone = '351'.$telefone;
$query = 'INSERT INTO raddb.Utente (telefone) VALUES (?)';
$stmt = $conn->prepare( $query );
$stmt->bind_param("s",$telefone);
$stmt->execute();

the second way would not work.

  • concatene antes: '$telefone = '351'. $telefone and then enter only $telefone

  • I’ll edit it! do it, concatene before $telefone = '351'.$telefone;

  • 2

    He deleted his comment.. Bruno, it is not interesting to delete comments or answers, since it can help other people with the same problems.. and it looks like me and @Virgilio Novic are talking to each other

  • @Gleidson Henrique deleted the comment because I thought it was my mistake, but after re-testing does not insert itself inside the Insert

Browser other questions tagged

You are not signed in. Login or sign up in order to post.