Jump to content

Recommended Posts

While I have sucessfully done this in the past, I cant get it to connect for this project.

 

Here is the link to my site:

 

http://royalvillicus.com/photo_voting/db_fns.php

 

Here is my code I am using to connect:

 

function db_connect() {
	$connection = mysql_connect('localhost', '5335', '12345678');

	if (!$connection) {
		return false;
	}
}

if (!mysql_select_db('photovote')) {
	return false;
}

return $connection;

if(db_connect()) {
	echo "connected to server";
} 

 

Thanks a lot for the help

this should do the job

function db_connect() 
{		
  $connection = mysql_connect('localhost', '5335', '12345678');				
  if(!$connection) 
  {			
    return false;		
  }
  else
  {
    if(!mysql_select_db('photovote')) 
    {		
      return false;	
    }	
    else
    {
      return $connection;
    }
  }	
}		


if(db_connect()) 
{		
  echo "connected to server";	
}

 

The problem is that you wrote function unfinished then u wrote return statement outside function body etc etc. It looks like u don't understand completely how the functions must be writen

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.