Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mysql connect problem

Status
Not open for further replies.

Rizzler

Technical User
Feb 9, 2006
43
SE
(SORRY, to make a double post but i got the topic of the other one wrong and i didint se an edit button :( )

anhow

hello, im using a php script to show the size of my sql database but im having a problem with connecting,

1: as i tryed to start the SQL server it's saying it is already running

2: i can connect to the database with mysql query browser and 2 schemes are added "mysql" and "rizzler"

3: after setting up the script (code bellow) i get nothing but a white screen, why is this? it's like it cant connect for some reason, still the mysql server is running.

i dont even get an error saying (cannot_connect) i use php5
***************CODE*************
<html>
<head><title>mySQL database size</title></head>
<body>
<h1>MySQL Database Size</h1>
<?php
function file_size_info($filesize) {
$bytes = array('KB', 'KB', 'MB', 'GB', 'TB'); # values are always displayed
if ($filesize < 1024) $filesize = 1; # in at least kilobytes.
for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024;
$file_size_info['size'] = ceil($filesize);
$file_size_info['type'] = $bytes[$i];
return $file_size_info;
}
$db_server = 'localhost';
$db_user = 'root';
$db_pwd = 'passwordwasremoved';
$db_name = 'rizzler';
$db_link = @mysql_connect($db_server, $db_user, $db_pwd)
or exit('Could not connect: ' . mysql_error());
$db = @mysql_select_db($db_name, $db_link)
or exit('Could not select database: ' . mysql_error());
// Calculate DB size by adding table size + index size:
$rows = mysql_query("SHOW TABLE STATUS");
$dbsize = 0;
while ($row = mysql_fetch_array($rows)) {
$dbsize += $row['Data_length'] + $row['Index_length'];
}
print "database size is: $dbsize bytes<br />";
print 'or<br />'; $dbsize = file_size_info($dbsize);
print "database size is: {$dbsize['size']} {$dbsize['type']}"; ?>
</body>
</html>
 
since i explained porly :) what i wanna know is why my php files cant connect to the mysql server yet the query browser can connect to it :/
 
It works okay for me.

I had to put the ?> on a new line.

Are you sure your parameters to mysql_connect() are correct?

Andrew
Hampshire, UK
 
ye towerbase, thing is this works on a friends server just fine
but as i put it on my server all i get is that white window. als o i tryed to install another php script on my server the otherday wich also shows nothing else then a blank screen
as both php files do this i wonder if there can be someting with my mysql server and if that is the case, what can it be ? :/ i thout i would get a conbnection error or someting maybe but it's just all blank.
 
First I would remove the "@" from the MYSQL commands. You want to see what is going on not suppress the error, so remove all the "@"; And Post back if you get any errors.




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
again double post since no edit button :>

anyhow as i se it EVERY php file with a mysql connection in it gives me a Blank white screen like that. normal php files work perfectly.. exaple is
 
This is turning into a PHP issue. Have you loaded the mysql extensions by uncommenting the relevant lines inside php.ini?

Code:
extension=php_mysql.dll

If still no go, i must advice you to post this issue in the PHP forum here on tek-tips. forum434. I'm sure they'll be able to help you more there with any settings that might be missing.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
;extension=php_mysql.dll

that above is copied from my php.in file and was under then "; Windows Extensions" lines

ok thanks for the help for far. i will tyr the php forums
 
Remove the ";" from the line if you haven't done so.




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
i did now and restarted IIS... didint work :< still white screen and now i have posted i nthe PHP section. if you thou wanna have a look on my php setting if i did anyting wrong here is the php.ini

 
In your PHP.ini the mysql extension line still has the ";" before it. take it out.

Second: after looking over your phpinfo page, it seems you have set display_errors to OFF. set it to ON in your PHP.ini. and run your script again.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
hey vacunita, i have now done these changes as you can se on what i wonder now is that if you look on it say that display error is still of even if it's set to on in the config (yes i restarted)

anyhow, i then added "error_reporting(E_ALL);" to the script and as you can se on the script i still get a white screen.

and now all the extensions are also added.
 
Are you editing the correct php.ini file? according to your phpinfo the one located in C:\PHP\php.ini.

I see you've asked this question in the PHP forum, lets move this discussion over there. i'll add a link to the thread here so everybody knows where this continues, but this way we can keep all answers in one thread.


This thread now continues in the PHP forum here: thread434-1315140.
Please post all comments and help in the other thread.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top