Server side linked mysql connection
Server side linked mysql connection
seveneleven
Posts: 6Questions: 0Answers: 0
Does anyone have an example of how you might setup the mysql connection with an external .php file?
I would like to use include_once in all my pages that require it.
My most recent attempt at the external file is this:
[code]
<?php
/*Edit the info below*/
$gaSql['server'] = "localhost";
$gaSql['db'] = "mydb";
$gaSql['user'] = "root";
$gaSql['password'] = "password";
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
mysql_query ( 'SET NAMES utf8' );
?>
[/code]
in my page (which was working fine before I started trying this) I get a json error. I call the connection.php file in line one.
Thanks
I would like to use include_once in all my pages that require it.
My most recent attempt at the external file is this:
[code]
<?php
/*Edit the info below*/
$gaSql['server'] = "localhost";
$gaSql['db'] = "mydb";
$gaSql['user'] = "root";
$gaSql['password'] = "password";
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
mysql_query ( 'SET NAMES utf8' );
?>
[/code]
in my page (which was working fine before I started trying this) I get a json error. I call the connection.php file in line one.
Thanks
This discussion has been closed.
Replies
What is the return from the server that you get? My guess is that if you look at the reply in Firebug your will get a warning from PHP saying that the problem is. There shouldn't any basic issue with doing an include on that above file, but there might be something like a path problem which is just creating a PHP error that needs to be fixed. If you can post the return, that would be very helpful.
Regards,
Allan