Forum Moderators: open

Message Too Old, No Replies

mysqli query working but statement not

         

Wayder

1:11 pm on Jun 8, 2023 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi,

Does anyone know why the first query returns 1 result and the second none.
IPAddress is varchar(15).


$dottedipaddress = '123.123.123.123';

$query = "SELECT IPAddress FROM ip_table WHERE IPAddress = '$dottedipaddress'";
$result = mysqli_query($mysqli,$query);


$stmtquery = "SELECT IPAddress FROM ip_table WHERE IPAddress = ?";
$stmt = mysqli_prepare($mysqli,$stmtquery);
mysqli_stmt_bind_param($stmt,'s',$dottedipaddress);
mysqli_stmt_execute($stmt);


Thank you

phranque

8:40 pm on Jun 8, 2023 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



have you examined the value of $stmt prior to the execute?

Wayder

9:16 pm on Jun 8, 2023 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi Phranque,

That was fine. I found howerver that I missed out

mysqli_stmt_get_result($stmt);

and was just counting without it.

Two hours of my life gone :(

Thank you

phranque

10:31 pm on Jun 8, 2023 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



oops...