CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 editing db_mysql.php file (PHP4/MySQL)

Print topic Send  topic

Author Message
elipsett
Posted: 01/18/2003, 10:20 PM

I am making a variety of PHP4/MySQL databases on my local win2k system and finding out what I can do with them, and with CCS. All of the MySQL DBs on my system have the same host, user name and ID, but after I upload them to their various host systems on the Internet, all of that information changes.

I assume it is possible to manually edit the db_mysql.php file, in the sections shown below (warning: parts deleted for brevity!).
Can anyone show me exactly how and where to specify the necessary information, or point me to an appropriate link with SPECIFIC information on the 'Net?

Thanks for your time!


=====
/* public: connection parameters */
var $Host = "";
var $Database = "";
var $User = "";
var $Password = "";
var $Persistent = false;

<snip>

function try_connect($Host = "", $User = "", $Password = "") {
/* Handle defaults */
if ("" == $Host) $Host = $this->Host;
if ("" == $User) $User = $this->User;
if ("" == $Password) $Password = $this->Password;

if($this->Persistent)
$this->Link_ID = @mysql_pconnect($Host, $User, $Password);
else
$this->Link_ID = @mysql_connect($Host, $User, $Password);

$is_connect = $this->Link_ID ? true : false;

return $is_connect;
}

/* public: connection management */
function connect($Database = "", $Host = "", $User = "", $Password = "") {
/* Handle defaults */
if ("" == $Database)
$Database = $this->Database;
if ("" == $Host)
$Host = $this->Host;
if ("" == $User)
$User = $this->User;
if ("" == $Password)
$Password = $this->Password;

/* establish connection, select database */
if ( 0 == $this->Link_ID ) {

if($this->Persistent)
$this->Link_ID=mysql_pconnect($Host, $User, $Password);
else
$this->Link_ID=mysql_connect($Host, $User, $Password);

if (!$this->Link_ID) {
$this->halt("pconnect($Host, $User, \$Password) failed.");
return 0;
}
=====

ronb
Posted: 01/19/2003, 9:08 AM

Well here's the beauty of CCS. Just change the setting under the menu project->settings->connection change the user name and password under server and publish your project to the new destination. That's it no need to alter anything by hand.

Ron
elipsett
Posted: 01/19/2003, 5:32 PM

Well, the MySQL DB was created at the host server by the server operator. I uploaded my copy of the SQL file to the site, and then accessed via Telnet to copy the data from my DB into theirs.
Forgive me for asking what are probably stupid questions, but:
I assume I can leave the host setting as localhost, which means all I need to do is change the userID and password, right? These are specified in several places in the setup screen, though: (1) Modify Connection/Design, (2) Modify Connection/Server, and (3) mysql driver default configuration.
Currently, (1) is blank, and (2) and (3) are set to "root" and the password for my system.
Which of these would the actual host userID/password be input into?

Thanks, and sorry for the novice questions <g>
elipsett
Posted: 01/19/2003, 6:10 PM

FYI, the command string used to transfer the data was:
mysql -hdbxx.pair.com -uyy -p zz <
aa.sql

where xx is the numeral of my DB server, yy my client name, xx the name of the (empty) MySQL db already existing on the server, and aa.sql the name of the SQL db that I uploaded by FTP.

HTH!
RonB
Posted: 01/21/2003, 12:33 AM

modify the server conection settings via project->settings->connections (modify connection) -> server tab. if the webserver runs on the same server as thye database you can keep server set to localhost. If not set it to the ip number of the database server. That's it. no need to change anything else except the username and password as they would have to be set to a valid user on the target database.

If the target database allows connection from an outside host use phpmyadmin to administer mysql. I find the GUI excelent and updating your databases is so much easier then typing in some command prompt. (but hey I'm from the real cut an past generation so typing in commands to do something that could easely be done with a click of a mouse just iritates the hell out of me)

RonB
elipsett
Posted: 01/22/2003, 4:23 AM

I tried changing that setting, and got the result below. THen I tried changing the setting in "TDX mysql default driver configuration" to the same thing (which is db39.pair.com in this case). (I replaced the userID with **) Same result:
=====
Warning: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /usr/www/users/hanshu/management/Candidates/db_mysql.php on line 93

Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /usr/www/users/hanshu/management/Candidates/db_mysql.php on line 93
Database error: pconnect(localhost, **, $Password) failed.
MySQL Error: ()
Session halted.
=====
Since "localhost" is mentioned, I assume it is still using the setting in the Poublishing/Server URL box, since that is the only place where "localhost" is mentioned any more. The paths in the PHP and HTML files seem to all be clean, starting from the folder they are placed in (no mention of localhost, root, my C drive or anything else messy).

Anything else I can try?
karl
Posted: 01/23/2003, 8:15 AM

Look at Common.php
and replace ????????

function Initialize()
{
$this->AbsolutePage = 0;
$this->PageSize = 0;
$this->DB = "";
$this->DBDatabase = "???????";
$this->DBHost = "localhost";
$this->DBUser = "?????????";
$this->DBPassword = "???????????";
$this->Persistent = true;
$this->RecordsCount = 0;
$this->RecordNumber = 0;
$this->DateFormat = Array("dd", "/", "mm", "/", "yyyy", " ", "HH", ":", "nn", ":", "ss");
$this->BooleanFormat = Array("Y", "N", "");
$this->Uppercase = false;
$this->Errors = New clsErrors();
}
elipsett
Posted: 01/23/2003, 5:19 PM

That was the answer! Thanks!

I still don't know precisely how to set the information in CCS so it produces the right code, but now that I know what the right code LOOKS LIKE, I can fiddle until i find it.

Will you take a check? Or should I just send gold bullion?


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.