problem when runing a funciton


Posted on 16th Feb 2014 07:03 pm by admin

I am trying to connect to database using a funciton in a functions.php

<?php
function connect_db_Blog (){
$con=mysql_connect("localhost","root","");
$db=mysql_select_db("blog",$con);
}
?>
which I then include with
include ("scripts/php_functions.php");

but when I run a code with

connect_db_Blog();

var_dump($db);
if (!$db) {

echo "sorry, cannot connect to database";

} else {
here comes some code..

I get: sorry , cennot connect to database message.

when I listen for $db with
var_dump($db);
I get int(0);
instead of int(1) which is needed to proceed with the code.

If I just try to connect to database without the include I dont get the error message i.e. .

No comments posted yet

Your Answer:

Login to answer
311 Like 17 Dislike
Previous forums Next forums
Other forums

FlashVar function how to insert variables
Hi guys. Im new in this forum and also new in php programming. Can you help me about this code?
<

Contents of variable not echoing
Hey guys, hopefully this is an easy one...

In this line, the variables are not echoing out. T

$variable $variables type question
I need to be able to designate an array element dynamically, so I thought to use a variable variable

blank page.... nothing is happening.
I'm new to a lot of this but in the last 24hrs have learned a lot.
Installed latest version of my

SAP Treasury - Commodities
We are running SAP ECC 6.0 with Treasury Activated.
EA-FIN is also activated (SFW5).

Checking if variable is 0 as opposed to NULL/Empty...
I'm trying to write some code that will retrieve a user's access level from my database and if it do

Validating time
Hi Guys

what do you think of the following approach to validate a 24hour time:

http://

Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :

random generation
hi

i need help with generating this

numbers from 1-12

i want to generate in ran

please help me in this update statment
hi every one

if I have table and this data in it

id name
10

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash