Boardunity & Video Forum

Boardunity & Video Forum (https://boardunity.de/)
-   Programmierung und Datenbanken (https://boardunity.de/programmierung-datenbanken-f23.html)
-   -   Problem mit mysqli->bind_param (https://boardunity.de/problem-mysqli-bind_param-t4574.html)

BB-BF-BM 16.12.2006 19:57

Problem mit mysqli->bind_param
 
Hallo zusammen!

Ich experimentiere gerade mit MySQLi, doch wenn ich folgenden Code einsetze, folgt immer ein Fehler:
PHP-Code:

<?php

$mtime 
microtime(1);
$sid '123412341234';
$ip '123.412.341.234';
$user_id 0;

require(
'./../general/includes/inc.db.php');
$db mysqli_init();
$db->real_connect($dbhost$dbuser$dbpasswd$dbname);

$stmt $db->prepare('INSERT INTO web_sessions (session_id, time_stamp, user_ip, user_agent, user_id) VALUES (?, ?, ?, ?, 0)');
$stmt->bind_param('sdss',
    
$sid,
    
$mtime,
    
$ip,
    
$_SERVER['HTTP_USER_AGENT']
);

?>

Zitat:

Warning: mysqli_stmt::bind_param() [function.mysqli-stmt-bind-param]: Number of variables doesn't match number of parameters in prepared statement in /www/htdocs/********/web/general/test.php on line 21

MaMo 16.12.2006 23:13

Hi,

mit dem 'sdss' sind das doch 5 Parameter, du hast in der Query aber nur 4 Platzhalter eingesetzt...

MaMo

BB-BF-BM 17.12.2006 08:22

laut Handbuch ist der erste Parameter dazu da, die Form der folgenden zu definieren:
Zitat:

class mysqli_stmt {
bool bind_param ( string types, mixed &var1 [, mixed &...] )
}

mysqli_stmt_bind_param() is used to bind variables for the parameter markers in the SQL statement that was passed to mysqli_prepare(). The string types contains one or more characters which specify the types for the corresponding bind variables
wobei i für integer steht, s für string, d für double und b für blob

MaMo 17.12.2006 11:52

Stimmt, daran hatte ich garnicht gedacht, sorry.:(


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:09 Uhr.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25