hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : mysqli_stmt_init() expects parameter 1 to be mysqli, boolean given
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

mysqli_stmt_init() expects parameter 1 to be mysqli, boolean given

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 11-25-2009, 05:44 AM
SmashedPumpkins SmashedPumpkins is offline
Junior Guru Wannabe
 
Join Date: Sep 2004
Location: CA
Posts: 59
Question

mysqli_stmt_init() expects parameter 1 to be mysqli, boolean given


I can not for the life of me figure out why these errors are occuring. Both of them are showing up. The form I have setup will not insert the data into my database. I have almost the exact same code setup on other pages and it works just fine. I must be missing something minor :\ Any help is greatly appreciated. First are the errors and next is the code. Thanks

Code:
Warning: mysqli_stmt_init() expects parameter 1 to be mysqli, boolean given in /home/rexburgd/public_html/submitdate.php on line 41

Warning: mysqli_stmt_prepare() expects parameter 1 to be mysqli_stmt, null given in /home/rexburgd/public_html/submitdate.php on line 43
PHP Code:
$datetitle=$_POST['datename'];
$imageurl=$_POST['imagelink'];
$datedetails=$_POST['datedetails'];
$intfacts=$_POST['interestingfacts'];
$directions=$_POST['directions'];
$tips=$_POST['tips'];
$category=$_POST['category'];
$rex_approval="0";

$server "localhost";
$username "removed";
$password "removed";
$database "removed";
$db = @mysqli_connect($server$username$password$database);

$stmt mysqli_stmt_init($db);
$sql "INSERT INTO dates(rex_category,rex_title,rex_details,rex_facts,rex_directions,rex_tips,rex_url,rex_approval) values (?,?,?,?,?,?,?,?)";
if(
mysqli_stmt_prepare($stmt$sql)) 
{
    
mysqli_stmt_bind_param($stmt"issssssi"$category,$datetitle,$datedetails,$intfacts,$directions,$tips,$imageurl,$rex_approval);
    
mysqli_stmt_execute($stmt);
    
mysqli_stmt_close($stmt);
    
mysqli_close($db);


Reply With Quote


Sponsored Links
  #2  
Old 11-25-2009, 09:26 AM
foobic foobic is online now
Community Liaison 2.0
 
Join Date: Feb 2005
Location: Australia
Posts: 5,120
The first (only) parameter to mysqli_stmt_init is $db. If that's not a mysqli object then your mysqli_connect probably didn't. Try removing the @ from the connect line so you see the errors it's generating.

__________________
Chris

"Learn from the mistakes of others. You can never live long enough to make them all yourself." - Groucho Marx

Reply With Quote
  #3  
Old 11-25-2009, 04:14 PM
SmashedPumpkins SmashedPumpkins is offline
Junior Guru Wannabe
 
Join Date: Sep 2004
Location: CA
Posts: 59
Quote:
Originally Posted by foobic View Post
The first (only) parameter to mysqli_stmt_init is $db. If that's not a mysqli object then your mysqli_connect probably didn't. Try removing the @ from the connect line so you see the errors it's generating.
Ahh okay now it's not allowing access to my database. Sadly I'm still not sure why it's not connecting. The user name and password is correct.

Code:
Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'rexburgd_english'@'localhost' (using password: YES)

Reply With Quote
Sponsored Links
  #4  
Old 11-25-2009, 04:32 PM
SmashedPumpkins SmashedPumpkins is offline
Junior Guru Wannabe
 
Join Date: Sep 2004
Location: CA
Posts: 59
Fixed, thanks! Stupid error!

Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mod_rewrite and boolean logic? avocado Hosting Security and Technology 2 05-02-2007 05:06 PM
Is there a limit to Wildcards in mysql boolean full text search? grabmail Programming Discussion 0 02-24-2006 05:12 PM
Warning: mysqli_query() expects parameter 1 to be mysqli, null given grabmail Programming Discussion 1 01-05-2006 10:28 PM
Advanced Boolean Search sasjamal Programming Discussion 14 05-19-2003 06:48 PM
php3-parameter with / instead of ? Martin Web Hosting 13 06-29-2001 04:25 PM

Related posts from TheWhir.com
Title Type Date Posted
Hosted Private Cloud Spending to Reach $24B in 2016: IDC Report Web Hosting News 2013-02-28 11:54:51
IO Hires Tech Vets in Former Groupon CIO, Apple Marketing VP Web Hosting News 2012-11-15 13:04:17
UK Web Host CWCS Launches Crest Hosting Brand, Targets Startup Hosting Web Hosting News 2012-09-06 11:23:44
Facebook IPO Filing Details Data Center Spending Web Hosting News 2012-02-02 11:37:57
Data Center Operator DuPont Fabros Selling Preferred Shares Web Hosting News 2012-01-13 13:44:19


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?