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 (){
Did you know?Explore Trending and Topic pages for more stories like this.
$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

$variable = $variable
Hello

Sorry if this is a really simple question but I have run out of ideas. Is there a reall

Php script to read msword file
hi,

I need to read a msword file and i want to print the contents in that word file.

i

Database connection failure
Hello All,

I am trying to create new connection to Oracle DB 10.1,
I could not see a

Bit manipulation program with binary operations
My homework is to create a program to scan in and add binary numbers and print them like so

Filtering an Array Based on Value
I have a very simple script set up that pulls data from a database and is output using this code:

DataTable Help Required
Hi all I am creating an app that utilises and MS Access back end and queries it quite a bit at vario

php and downloading
I want to use a php script to create two files. Then I want it to redirect (or whatever) to have tho

image upload, resize THEN submit form
Ok so I have a form that requires the user to upload an image, and then do something with that image

Execure stored procedure on a timer
Can someone tell me an easier way to execute a stored procedure on a timer? I am using Oracle 10g R

My query is being run with no results.
I have this.

Code: function DropUser($duser_id, $user_email, $user_username) {

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