Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
Error fatal: llamada a una función miembro bind_param () en una matriz JSON que no es un objeto

He buscado esto aquí y en Internet, pero no puedo encontrar una solución.

Estoy publicando una matriz JSON como:

 [{"phone_number":"+12345678"}, {"phone_number":"+23456789"}, {"phone_number":"34567890"}, {"phone_number":"45678901"} etc... etc...

Aquí está mi código:

 <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); require('dbConnect.php'); //post all contacts in my phone as a JSON array $json = $_POST['phonenumber']; $array = json_decode($json); foreach ($array as $value) { $phonenumber = $value->phone_number; $stmt = $con->prepare('SELECT * FROM user WHERE username = ?'); $stmt->bind_param('s', $phonenumber); $stmt->execute(); echo $phonenumber . "<br>"; var_dump($stmt); } ?>

Solo el primer número de teléfono en la matriz se repite correctamente. Entonces obtengo:

 object(mysqli_stmt)#131 (10) { ["affected_rows"]=> int(-1) ["insert_id"]=> int(0) ["num_rows"]=> int(0) ["param_count"]=> int(1) ["field_count"]=> int(2) ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["sqlstate"]=> string(5) "00000" ["id"]=> int(1) } Fatal error: Call to a member function bind_param() on a non-object in /var/www/html/checkcontact.php on line 28

La línea 28 es: $stmt->bind_param('s', $phonenumber);

Cuando uso este código (aunque no es seguro) funciona bien, todos los números de teléfono se repiten correctamente:

 <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); require('dbConnect.php'); //post all contacts in my phone as a JSON array $json = $_POST['phonenumber']; $array = json_decode($json); foreach ($array as $value) { $phonenumber = $value->phone_number; $sql = "SELECT * FROM user WHERE username = '$phonenumber'"; $result = mysqli_query($con, $sql); echo $phonenumber . "<br>"; } ?>
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!