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!

php mysql problem

Status
Not open for further replies.

Rizzler

Technical User
Feb 9, 2006
43
SE
as said in this topic
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 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
what i wanna know is why my php files cant connect to the mysql server yet the query browser can connect to it :/

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.

i tryed to get error to be shown

here is it with all @'s removed
still i have a blank page

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
is there ANYONE that know what could cause this problem ? in my php.ini file ;extension=php_mysql.dll is under the "; Windows Extensions" lines

here is mu php.ini if anyone wanna se if i made a misstake (had to make a txt file of it)
 
it does not look (from your phpinfo) that you have enabled the mysql extension in your php.ini file.

you are getting a blank screen because you have set display_errors in your php file to off.

the above two issues can be fixed by editing your php.ini file and then restarting your server.

please read sleipnir214's FAQ on debugging errors (faq434-2999) and follow the manual on enabling mysql.
 
hey jpadie, 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 file and as you can se on the script i still get a white screen.

and now all the extensions are also added.
 
Just so everybody knows where this is coming from, Rizzler started this question in the MYSQL forum, but since it evolved into a PHP question about configurations and php.ini settings. I told him to post here.

The original thread is: thread436-1314775.
And I'll quote what i said there here:

Are you editing the correct php.ini file? according to your phpinfo the one located in C:\PHP\php.ini.

And you forgot to remove the ";" from the display_errors directive. just delete it on that line only nothing else.


----------------------------------
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.
 
Rizzler

display errors is still set to off in your php.ini file (as shown in php2.txt). try turning it ON
Code:
display_errors = ON
 
im very sorry, i was looking at the wrong "display_errors" line, now it's tured on and php info say it's also on.

sizeofmysql now gives an error "Fatal error: Call to undefined function mysql_connect() in Q:\Webroot\sizeofmysql2.php on line 18"

code is added bellow, on line 18 there is "$db_name = 'rizzler';" as i understand it it cant find anydatabase with the name rizzler? still i have added 2 schemes to my mysql server with Mysql query browser. these 2 scemes are called "rizzler" and "mysql"

for some reason i feel i missunderstood someting now! :p
 
EDIT:

as said erlier my sql scripts now give errors and i have as said erlier also 2 schemes on my sql server called "mysql" and "rizzler" first i got an error saying that the database didint exist, so i changed it to "mysql" and then it worked, now it's just an error that i know how do fix and i thank you all for the help getting this working! ;) so i just need help with this last thing. why do it recognize "mysql" as a database and now "rizzler" ?

 
Fatal error: Call to undefined function mysql_connect() in Q:\Webroot\sizeofmysql2.php on line 18
this means that php is not able to load the mysql extension properly. or it could be that you have not enabled the extension but this is not evidenced by your php.ini file.

i don't really know what you mean by "recognize ... as a database" so can't assist with the second question.
 
Jpadie, nwm that qustion, i se that it is stupid right now. down Bellow are the code and on line 18 this is shown ""$db_link = mysql_connect($db_server, $db_user, $db_pwd)

also "this means that php is not able to load the mysql extension properly" as you said i have now enabled the extension and ichecked that the files are in the extension folder wich they are. :/

<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 = '6822';
$db_name = 'mysql';
$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>
 
as i understand it, i get the error ""$db_link = mysql_connect($db_server, $db_user, $db_pwd) because my mysql server is not working like it should, i thout it may be off, so i used the startup command and it said that it already is running, i connected with mysql administrator and indeed it's running, what can not be working properly with it since i get that error?
 
i have gotten it to work now, and i thank you very very much for the support, the problem was that php_mysql.dll was corrupt nad i dunno how that could ever happen.

now i have one last question, i noticed that the uptime for my server in php script are totaly wrong, if you check at the bottom it's counting awfully wrong, so do this script
here is the code
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top