close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Will Dynamic connections help solve my problem

Thread begun 7/05/2012 5:52 pm by phil107723 | Last modified 7/09/2012 1:28 pm by phil107723 | 5834 views | 2 replies |

phil107723

Will Dynamic connections help solve my problem

I keep getting this error message:
Warning: mysql_pconnect(): MySQL server has gone away in C:\HostingSpaces\TRICKSTAR\ericksenhonda.co.nz\wwwroot\connections\dbConn.php on line 9

And I was wanting to know would using Dynamic connections help improve the connection used by DW.
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_dbConn = "mysql_server";
$database_dbConn = "database_name;
$username_dbConn = "username";
$password_dbConn = "password";
$dbConn = mysql_pconnect($hostname_dbConn, $username_dbConn, $password_dbConn) or trigger_error(mysql_error(),E_USER_ERROR);
?>

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

Dynamic connections probably wont help with this issue.

By default, Dreamweaver MySQL Connections (And Dynamic Coneections) use mysql_pconnect() to create the connection, this is a Persistant connection. On some servers that only allow a certain number of connections at a time, this can cause the issue you are running into. The fix for this is to use a non persistent connection by changing the mysql_pconnect() function call to mysql_connect()

change this line:

php:
$dbConn = mysql_pconnect($hostname_dbConn, $username_dbConn, $password_dbConn) or trigger_error(mysql_error(),E_USER_ERROR);




to:

php:
$dbConn = mysql_connect($hostname_dbConn, $username_dbConn, $password_dbConn) or trigger_error(mysql_error(),E_USER_ERROR);
Sign in to reply to this post

phil107723

Thanks Jason I'll give it a try.

Sign in to reply to this post

adamuabu445910

It still wont connect

Originally Said By: Jason Byrnes
  Dynamic connections probably wont help with this issue.

By default, Dreamweaver MySQL Connections (And Dynamic Coneections) use mysql_pconnect() to create the connection, this is a Persistant connection. On some servers that only allow a certain number of connections at a time, this can cause the issue you are running into. The fix for this is to use a non persistent connection by changing the mysql_pconnect() function call to mysql_connect()

change this line:
php:
$dbConn = mysql_pconnect($hostname_dbConn, $username_dbConn, $password_dbConn) or trigger_error(mysql_error(),E_USER_ERROR);



to:
php:
$dbConn = mysql_connect($hostname_dbConn, $username_dbConn, $password_dbConn) or trigger_error(mysql_error(),E_USER_ERROR);
  




I have same problem here. I removed the (p) in pconnect and I still get the same error

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'admins'@'localhost' (using password: YES) in /home/sheieorg/public_html/Connections/sya.php on line 9

Fatal error: Access denied for user 'admins'@'localhost' (using password: YES) in /home/sheieorg/public_html/Connections/sya.php on line 9

Sign in to reply to this post

Jason ByrnesWebAssist

the error message means that either the User Name or password being used in your connection are not correct.

double check that you have the correct username and password in the connection for accessing the SQL server.

Sign in to reply to this post

adamuabu445910

Thanks Jason

I was able to get rid of that error fixing the username and password, but I now get a new error at the top of my website's content:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/sheieorg/public_html/Connections/sya.php:11) in /home/sheieorg/public_html/index.php on line 37

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/sheieorg/public_html/Connections/sya.php:11) in /home/sheieorg/public_html/index.php on line 37

I really need help with this, thanks.

Sign in to reply to this post

Jason ByrnesWebAssist

the error means that there is output on the Connections/sya.php file outside of the php tags.

it is reporting the problem at line 11.

look for a blank space after the closing php tag ?> or a blank line.

see this thread for details:
showthread.php?t=19285

Sign in to reply to this post

adamuabu445910

Thanks, the error is off, still..

Thanks a million Jason, on checking I discovered I had 2 PHP closing tags. I am new to dynamic websites, have uploaded all the files using cpanel, but on login in, I now get "no database selected" please how do I connect my database. it works perfect locally.


<?php require_once('Connections/sya.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username:'])) {
$loginUsername=$_POST['username:'];
$password=$_POST['Password:'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "trainingindex.php";
$MM_redirectLoginFailed = "index.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_sya, $sya);

$LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $sya) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>

Sign in to reply to this post

adamuabu445910

Realy need help with this

On login in, I get a "no database selected" error. below is the code:


<?php require_once('Connections/sya.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username:'])) {
$loginUsername=$_POST['username:'];
$password=$_POST['Password:'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "trainingindex.php";
$MM_redirectLoginFailed = "index.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_sya, $sya);

$LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $sya) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>

Sign in to reply to this post

Jason ByrnesWebAssist

The no database selected error suggests a problem with the MySQL Login credentials,

make sure you have the correct server name, username, password and database name in the connection file.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...