Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-19-2005, 10:46 AM   #1
Morg
1st party software!
 
Morg's Avatar
 
Join Date: Nov 2003
Location: South Africa
Posts: 916
Default mysqli_connect giving errors

Hi all

Ok, so i am trying to connect to a mySql DB using PHP5...

I am geting some odd error that says:

Code:
Fatal error: Trying to clone an uncloneable object of class mysqli in c:\program files\apache group\Apache\htdocs\dbconnect.php on line 9
I got that code out of a tutorial, and its wrong... I am so lost...

If anyone has any ideas, please let me know.
Thanks
Morg is offline   Reply With Quote
Old 09-20-2005, 01:43 AM   #2
mmm..pi..3.14..
/(bb|[^b]{2})/
 
mmm..pi..3.14..'s Avatar
 
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
Default

try "mysql_connect" instead of "mysqli_connect"
__________________
Eric Hainer
Unleaded Software
970.581.3387
Email: Eric followed by the AT symbol, unleaded software (one word) DOT com
Denver Web Design
mmm..pi..3.14.. is offline   Reply With Quote
Old 09-20-2005, 07:11 AM   #3
Morg
1st party software!
 
Morg's Avatar
 
Join Date: Nov 2003
Location: South Africa
Posts: 916
Default



I dont know what I am doing wrong... Maybe its the way my server and PHP is set up...?

When I mysql instead of mysqli, i get the following error:
Code:
Fatal error: Class 'mysql' not found in 
c:\program files\apache group\Apache\htdocs\dbconnect.php on line 9
Here is what I have in my page:
Code:
echo 'hello';
$db = new mysql('localhost','root','passme');
if(mysql_connect_errno()){
	echo 'Error: Could not connect to database. Please try again later.';
	exit;
}
$query = "select * from tbluser";
$result = $db->query($query);
$num_results = $result->num_rows;
echo 'Number of entries found: '.$num_results;
the echo for hello is just to test if it is actually running...

Any help would be greatly appreciated..

Thanks
Morg is offline   Reply With Quote
Old 09-20-2005, 07:24 AM   #4
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default

ActionScript Code:
$db=mysql_connect(DB_server,DB_username,DB_password) or die('error0='.mysql_error()); @mysql_select_db(DB_database) or die('error1='.mysql_error()); $query = "select * from tbluser"; $result = mysql_query($query) or die('error2='.mysql_error()); //DB_server,DB_username,DB_password,DB_database //replace them whit the proper value for your DB
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef is offline   Reply With Quote
Old 09-20-2005, 10:33 AM   #5
Morg
1st party software!
 
Morg's Avatar
 
Join Date: Nov 2003
Location: South Africa
Posts: 916
Default

Hi.

Yeah, cool. That seems to work. Thanks!

But, howecome the sqli does not work? I have PHP 5 installed, and have the extension for it installed aswell... Very strange...
Morg is offline   Reply With Quote
Old 09-20-2005, 11:47 AM   #6
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default

what shoud "sqli" by ????

never heard of it !
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef is offline   Reply With Quote
Old 09-20-2005, 11:54 AM   #7
Morg
1st party software!
 
Morg's Avatar
 
Join Date: Nov 2003
Location: South Africa
Posts: 916
Default

Well, apparently, it is the new way of connecting to DB in PHP5... the i stands for ... improved.

At least, thats what the book says.
Morg is offline   Reply With Quote
Old 09-20-2005, 12:14 PM   #8
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default

yeh you are right

but whit out to see your code i can't tell you why
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef is offline   Reply With Quote
Old 09-20-2005, 12:25 PM   #9
Morg
1st party software!
 
Morg's Avatar
 
Join Date: Nov 2003
Location: South Africa
Posts: 916
Default

Dammit... seems I posted the wrong code earlier...

This is the coe that uses the msqli stuff >>
Code:
echo 'hello';
$db = new mysqli('localhost','root','passme');
if(mysqli_connect_errno()){
	echo 'Error: Could not connect to database. Please try again later.';
	exit;
}
$query = "select * from tbluser";
Morg is offline   Reply With Quote
Old 09-20-2005, 12:35 PM   #10
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default

Hmmm

i am to tiered in the moment even ower see you have posted the corect code earlyer
sorry

try this

http://es2.php.net/manual/en/function.mysqli-query.php

i go
Zzzzzzzzzzz.....
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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


All times are GMT. The time now is 03:32 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.