Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP prepared statement giving me error 0
    primarykey
    data
    text
    <p>This has been frustrating me for more than an hour, any help would be appreciated.</p> <p>I have "marked" the offending code with a comment below</p> <pre><code> $hostt = "localhost"; $db_database = "dekit_ryan"; $db_username = "dekit_ry"; $db_password= "s%g0oM"; $link = mysqli_connect($hostt , $db_username, $db_password, $db_database); if (!$link) { printf("Unable to connect to DB, the error is: %s\n", mysqli_connect_error()); exit(); } // ************* Problem seems to be with the below line *********** $stmt = mysqli_prepare($link, "INSERT INTO campaign(cname,public_ref_name,redirect_to) VALUES (?, ?, ?)"); mysqli_stmt_bind_param($cname, $pub_ref_name, $url); mysqli_stmt_execute($stmt); // Check if the row was successfully inserted or spit out an error if(mysqli_stmt_affected_rows($stmt) != 1) { return "Error: Problem inserting a record into the database, exiting..." . mysqli_errno($link); exit; } </code></pre> <p>When I run the script I always get:</p> <p><strong>Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, string given in /home/dekit3/public_html/adTracking/classes/AdsTracking.php on line 44</strong></p> <p>Error: Problem inserting a record into the database, exiting...0</p> <p>var dump</p> <pre><code>object(mysqli)#2 (18) { ["affected_rows"]=&gt; int(0) ["client_info"]=&gt; string(6) "5.1.62" ["client_version"]=&gt; int(50162) ["connect_errno"]=&gt; int(0) ["connect_error"]=&gt; NULL ["errno"]=&gt; int(0) ["error"]=&gt; string(0) "" ["field_count"]=&gt; int(0) ["host_info"]=&gt; string(25) "Localhost via UNIX socket" ["info"]=&gt; NULL ["insert_id"]=&gt; int(0) ["server_info"]=&gt; string(10) "5.1.62-cll" ["server_version"]=&gt; int(50162) ["stat"]=&gt; string(151) "Uptime: 1210463 Threads: 10 Questions: 45999394 Slow queries: 1585 Opens: 3541810 Flush tables: 57 Open tables: 256 Queries per second avg: 38.1" ["sqlstate"]=&gt; string(5) "00000" ["protocol_version"]=&gt; int(10) ["thread_id"]=&gt; int(1861790) ["warning_count"]=&gt; int(0) } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload