Hey,i have a problem with DATABASE CONNECTION :\

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mekha
Forum Contributor
Posts: 112
Joined: Sat Mar 31, 2012 6:50 am

Hey,i have a problem with DATABASE CONNECTION :\

Post by mekha »

hi, i have a MYSQLi connection code:

Code: Select all

<?php
	$dbhost = 'localhost';
	$dbuser = 'user';
	$dbpass = 'pass';
	$dbname = 'dbname';
	
	$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
	if ($mysqli->connect_errno) {
		printf("Connect failed: %s\n", $mysqli->connect_error);
		exit();
	}
	
	//$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
	
    //mysql_select_db($dbname,$conn);
	//$mysqli->query("SET NAMES 'utf8' COLLATE 'utf8_general_ci'");
	function runQuery($sql)
	{
		 if($stmt = $mysqli -> prepare($sql)) {

		 $stmt->execute();
		 $stmt -> bind_result($result);
		 }
	}
	function exeQuery($stmt)
	{
		
		//$mysqli->query($sql);
	}
?>
, can u tell me what the errors in my code :\ ?
this is a mysqli not mysql!!!
---
thank you.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Hey,i have a problem with DATABASE CONNECTION :\

Post by social_experiment »

what happens when you use the code
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply