maceotago Posted November 11, 2008 Share Posted November 11, 2008 Hello All, Apologies if this has come up before. I am suddenly getting the following errors (in the error log) on a website I am maintaining as follows. I'm not sure if I accidently changed something. My PHP knowledge is average. PHP Warning: mysql_db_query() [<a href='function.mysql-db-query'>function.mysql-db-query</a>]: Access denied for user 'username'@'localhost' (using password: NO) in /home/name/public_html/home.php on line 77 PHP Warning: mysql_db_query() [<a href='function.mysql-db-query'>function.mysql-db-query</a>]: A link to the server could not be established in /home/name/public_html/home.php on line 77 The error on the browser is: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@mysite.net and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache/2.2.10 (Unix) mod_ssl/2.2.10 OpenSSL/0.9.7a mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at wwwmysitenet Port 80 Any help most appreciated. Lyndon Quote Link to comment Share on other sites More sharing options...
Mchl Posted November 11, 2008 Share Posted November 11, 2008 Access denied for user 'username'@'localhost' (using password: NO) This means that PHP script cannot connect to database server with credentials (username and password) you have supplied. In fact it says you have not supplied the password at all. Check the part of your script, where you define these credentials, and make sure they're set as appropriate. Quote Link to comment Share on other sites More sharing options...
BioBob Posted November 11, 2008 Share Posted November 11, 2008 /agree You should have a mysql_connect() call somewhere in the script before trying to query the mysql db. That is where your user / pw should be declared. If youre using variables in there, maybe echo those and make sure they arent undefined. Quote Link to comment Share on other sites More sharing options...
maceotago Posted November 14, 2008 Author Share Posted November 14, 2008 Thanks for your answers. Things still are not working. The database connection is defined as a variable in index.php ie. $connect = mysql_connect etc etc. I have checked the credentials and they are correct. The error log (as above) points to the following bit of code: <?php page_footer(); } else { $count_flights = mysql_db_query("db", "SELECT * FROM `web_flights`")or die (mysql_error()); $flights = mysql_num_rows($count_flights); $count_members = mysql_db_query("db", "SELECT * FROM `users_db`"); $members = mysql_num_rows($count_members); $count_pilots = mysql_db_query("db", "SELECT * FROM `users_db` WHERE usr_status='2'"); $pilots = mysql_num_rows($count_pilots); $count_pireps = mysql_db_query("db", "SELECT * FROM `users_pireps` WHERE pirep_extra='1'"); $pireps = mysql_num_rows($count_pireps); $sum_distance = mysql_db_query("db", "SELECT web_flights.flight_distance FROM `users_pireps`, `web_flights` WHERE users_pireps.pirep_status='2' AND users_pireps.pirep_type='c' AND users_pireps.pirep_extra='1' AND users_pireps.pirep_flight = web_flights.flight_number"); $tot_distance = "0.0"; while($row = mysql_fetch_array($sum_distance)) { $flt_distance = $row['flight_distance']; $tot_distance = $tot_distance + $flt_distance; } ?> Any ideas? Quote Link to comment Share on other sites More sharing options...
Mchl Posted November 14, 2008 Share Posted November 14, 2008 I assume that index.php is included before this piece of code? Quote Link to comment Share on other sites More sharing options...
maceotago Posted November 14, 2008 Author Share Posted November 14, 2008 Here is the top piece of code. You can see the variable $connect mentioned. <?php if($view == "home") { page_header("hm","Welcome my webpage"); $today_history = mysql_db_query("db", "SELECT * FROM `web_news` WHERE nw_stamp <= (UNIX_TIMESTAMP() - 60*60*24*365) ORDER BY `nw_stamp` DESC LIMIT 1", $connect); $today_row = mysql_fetch_array($today_history); $nw_sql = mysql_db_query("db", "SELECT * FROM `web_news` ORDER BY `nw_stamp` DESC LIMIT 8", $connect); ?> <table border="0" width="660" cellspacing="3" cellpadding="0"> <tr> <td class="default" valign="top"> <table border="0" width="460" cellspacing="0" cellpadding="2"> <?php while($nw_row = mysql_fetch_array($nw_sql)) { ?> Quote Link to comment Share on other sites More sharing options...
Mchl Posted November 14, 2008 Share Posted November 14, 2008 I do, but I don't see index.php included anywhere. If you want database connection made in index.php available in home.php, you have to include this file. Quote Link to comment Share on other sites More sharing options...
maceotago Posted November 14, 2008 Author Share Posted November 14, 2008 Ok .. what would be the best way (and best place) to do this..... I'm learning sorry! Quote Link to comment Share on other sites More sharing options...
Mchl Posted November 14, 2008 Share Posted November 14, 2008 The best way would be, to create one more file, called for example 'dbconnection.php' In this file you should create a database connection, for example like this: <?php //Try connecting to mysql $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); //If not succesful, display error message if (!$link) { die("Could not connect to mysql: " . mysql_error()); } //here you select "db" as a database you will be working with, so that you can use mysql_query() instead of mysql_db_query() $db_selected = mysql_select_db("db", $link); //again: error message if selecting database fails if (!$db_selected) { die ("Can't use database 'db' : " . mysql_error()); } ?> then at the beginning of each file, that will be using database, you have to put require_once("dbconnection.php"); And after you can do your queries like that $result = mysql_query("SELECT * FROM..."); //no need to add database name, or database connection (as long as you use only one database) Quote Link to comment Share on other sites More sharing options...
maceotago Posted December 29, 2008 Author Share Posted December 29, 2008 ok.... I'm still on this problem!!!!! I can't figure it out. Here is the page that is not working. I have also attached the page the defines the variables. <?php if($view == "home") { page_header("hm","Welcome to Mysite"); $today_history = mysql_db_query("my_db", "SELECT * FROM `web_news` WHERE nw_stamp <= (UNIX_TIMESTAMP() - 60*60*24*365) ORDER BY `nw_stamp` DESC LIMIT 1", $connect); $today_row = mysql_fetch_array($today_history); $nw_sql = mysql_db_query("my_db", "SELECT * FROM `web_news` ORDER BY `nw_stamp` DESC LIMIT 8", $connect); ?> <table border="0" width="660" cellspacing="3" cellpadding="0"> <tr> <td class="default" valign="top"> <table border="0" width="460" cellspacing="0" cellpadding="2"> <?php while($nw_row = mysql_fetch_array($nw_sql)) { ?> <tr> <td class="default"><a href="./?view=hr/news&nid=<?=$nw_row['nw_id']?>"><b><?=$nw_row['nw_title']?></b></a></td> </tr> <tr> <td class="small"><?= date("l, F j, Y \\a\\t g:i A (T)", $nw_row['nw_stamp']); ?></td> </tr> <tr> <td class="default"><?php printf("%.130s...", $nw_row['nw_body']); ?></td> </tr> <?php } ?> </table></td> <td valign="top" align="center"><img src="./images/spacer/grey.gif" width="1" height="500" alt=""></td> <td class="default" valign="top"> <table border="0" width="180" cellspacing="1" cellpadding="1"> <tr> <td colspan="2" class="default"><b>Today in History</b><br><a href="./?view=hr/news&nid=<?=$today_row['nw_id']?>"><?=$today_row['nw_title']?></a></td> </tr> <tr> <td colspan="2" class="default"><p align="justify"><?php printf("%.500s...", $today_row['nw_body']); ?></p></td> </tr> <tr> <td colspan="2"><hr></td> </tr> <tr> <td class="default"><b>Total Members</b></td> <td class="default" align="right"><?php doCount("users_db",""); ?></td> </tr> <tr> <td class="default"><b>Active Pilots</b></td> <td class="default" align="right"><?php doCount("users_db","WHERE usr_status='2'"); ?></td> </tr> <tr> <td class="default"><b>Retired Pilots</b></td> <td class="default" align="right"><?php doCount("users_db","WHERE usr_status='3'"); ?></td> </tr> </table> <table border="0" width="180" cellspacing="1" cellpadding="0"> <tr> <td colspan="2"><hr></td> </tr> <tr> <td colspan="2" class="default"><form action="./index.php" method="post"><input type="hidden" name="do" value="newssearch"><b>News Search</b><br><input type="text" name="keyword" size="25"></td> </tr> <tr> <td class="deafult"><input type="submit" name="perform" value="Search"></form></td> </tr> </table> </td> </tr> </table> <?php page_footer(); } else { $count_flights = mysql_db_query("my_db", "SELECT * FROM `web_flights`")or die (mysql_error()); $flights = mysql_num_rows($count_flights); $count_members = mysql_db_query("my_db", "SELECT * FROM `users_db`"); $members = mysql_num_rows($count_members); $count_pilots = mysql_db_query("my_db", "SELECT * FROM `users_db` WHERE usr_status='2'"); $pilots = mysql_num_rows($count_pilots); $count_pireps = mysql_db_query("my_db", "SELECT * FROM `users_pireps` WHERE pirep_extra='1'"); $pireps = mysql_num_rows($count_pireps); $sum_distance = mysql_db_query("my_db", "SELECT web_flights.flight_distance FROM `users_pireps`, `web_flights` WHERE users_pireps.pirep_status='2' AND users_pireps.pirep_type='c' AND users_pireps.pirep_extra='1' AND users_pireps.pirep_flight = web_flights.flight_number"); $tot_distance = "0.0"; while($row = mysql_fetch_array($sum_distance)) { $flt_distance = $row['flight_distance']; $tot_distance = $tot_distance + $flt_distance; } ?> <table border="0" width="700" cellspacing="0" cellpadding="0" align="center" bgcolor="#003366"> <tr> <td colspan="2" align="center"><img src="./images/spacer/clear.gif" width="20" height="10" alt=""></td> </tr> <tr> <td width="500" class="titlew"> <b>Welcome to My Site</b></td> <td width="200" class="smallw" align="center"><?php echo date("F j, Y, H:i T"); ?></td> </tr> <tr> <td align="center"> <table border="0" width="480" cellspacing="1" cellpadding="2"> <?php $nw_sql = mysql_db_query("my_db", "SELECT * FROM `web_news` ORDER BY `nw_stamp` DESC LIMIT 3", $connect); while($nw_row = mysql_fetch_array($nw_sql)) { ?> <tr> <td class="defaultw"><a href="./?view=hr/news&nid=<?=$nw_row['nw_id']?>" class="bar"><b><?=$nw_row['nw_title']?></b></a></td> </tr> <tr> <td class="smallw"><?= date("l, F j, Y \\a\\t g:i A (T)", $nw_row['nw_stamp']); ?></td> </tr> <tr> <td class="defaultw"><? printf("%.150s...", $nw_row['nw_body']); ?></td> </tr> <?php } ?> </table></td> <td width="200" align="center" valign="top"> <table border="0" width="180" cellspacing="1" cellpadding="2"> <tr> <td colspan="2" class="titlew"><b>Community Stats</b></td> </tr> <tr> <td class="defaultw"><b>Total Members</b> <?=$members?></td> </tr> <tr> <td class="defaultw"><b>Active Pilots</b> <?=$pilots?></td> </tr> <tr> <td class="defaultw"><b>Routes to fly</b> <?=$flights?></td> </tr> <tr> <td class="defaultw"><b>Flights Flown</b> <?=$pireps?></td> </tr> <tr> <td class="defaultw"><b>Distance</b> <?=$tot_distance?></td> </tr> </table></td> </tr> </table> <?php } ?> <? //extract($_GET); //extract($_POST); //error_reporting(E_ALL); ini_set('display_errors', 'false'); session_start(); $view = $_REQUEST['view']; $admin = $_REQUEST['admin']; $perform = $_REQUEST['perform']; $pilot = $_REQUEST['pilot']; $v = $_REQUEST['v']; $do = $_REQUEST['do']; // ./admin $modify = $_REQUEST['modify']; // ./pireps $pirep = $_REQUEST['pirep']; // bin/home $nid = $_REQUEST['nid']; $keyword = $_REQUEST['keyword']; // pc/event $event_month = $_REQUEST['event_month']; $event_day = $_REQUEST['event_day']; $event_year = $_REQUEST['event_year']; $event_hh = $_REQUEST['event_hh']; $event_mm = $_REQUEST['event_mm']; $event_length = $_REQUEST['event_length']; $event_title = $_REQUEST['event_title']; $event_desc = $_REQUEST['event_desc']; $event_flight = $_REQUEST['event_flight']; $event_ip = $_REQUEST['event_ip']; // pc/inbox $multi = $_REQUEST['multi']; $mail = $_REQUEST['mail']; // pc/index $form_email = $_REQUEST['form_email']; $form_pid = $_REQUEST['form_pid']; $form_pw = $_REQUEST['form_pw']; // pc/mymail $reply = $_REQUEST['reply']; $forward = $_REQUEST['forward']; // pc/profile $email1 = $_REQUEST['email1']; $email2 = $_REQUEST['email2']; $country = $_REQUEST['country']; $vatsim = $_REQUEST['vatsim']; $aim = $_REQUEST['aim']; $icq = $_REQUEST['icq']; $msn = $_REQUEST['msn']; $yim = $_REQUEST['yim']; $signature = $_REQUEST['signature']; $comments = $_REQUEST['comments']; $pilot = $_REQUEST['pilot']; // pc/search $search_type = $_REQUEST['search_type']; $search_flight_num = $_REQUEST['search_flight_num']; $search_type = $_REQUEST['search_type']; $search_da = $_REQUEST['search_da']; $search_flight_da = $_REQUEST['search_flight_da']; $search_aa = $_REQUEST['search_aa']; $search_flight_aa = $_REQUEST['search_flight_aa']; $search_rating = $_REQUEST['search_rating']; $search_flight_rating = $_REQUEST['search_flight_rating']; $search_aircraft = $_REQUEST['search_aircraft']; $search_flight_aircraft = $_REQUEST['search_flight_aircraft']; $search_pilot_lname = $_REQUEST['search_pilot_lname']; $search_pilot_fname = $_REQUEST['search_pilot_fname']; $search_pilot_usr = $_REQUEST['search_pilot_usr']; $search_regdate_usr = $_REQUEST['search_regdate_usr']; $cat = $_REQUEST['cat']; $save_flight = $_REQUEST['save_flight']; $search = $_REQUEST['search']; $flight = $_REQUEST['flight']; $da = $_REQUEST['da']; $aa = $_REQUEST['aa']; $ac = $_REQUEST['ac']; // pc/pirep $pirep_month = $_REQUEST['pirep_month']; $pirep_day = $_REQUEST['pirep_day']; $pirep_year = $_REQUEST['pirep_year']; $pirep_dep_hh = $_REQUEST['pirep_dep_hh']; $pirep_dep_mm = $_REQUEST['pirep_dep_mm']; $pirep_fl_hh = $_REQUEST['pirep_fl_hh']; $pirep_fl_mm = $_REQUEST['pirep_fl_mm']; $pirep_type = $_REQUEST['pirep_type']; $company_fl_num = $_REQUEST['company_fl_num']; $pirep_type = $_REQUEST['pirep_type']; $personal_da = $_REQUEST['personal_da']; $personal_aa = $_REQUEST['personal_aa']; $personal_flight_aircraft = $_REQUEST['personal_flight_aircraft']; $tour_fl = $_REQUEST['tour_fl']; $tour_fl_num = $_REQUEST['tour_fl_num']; $pirep_route = $_REQUEST['pirep_route']; $pirep_comments = $_REQUEST['pirep_comments']; // pc/send $ref = $_REQUEST['ref']; $compose_to = $_REQUEST['compose_to']; $compose_func = $_REQUEST['compose_func']; $compose_cc = $_REQUEST['compose_cc']; $compose_bcc = $_REQUEST['compose_bcc']; $compose_subject = $_REQUEST['compose_subject']; $compose_body = $_REQUEST['compose_body']; $compose_signature = $_REQUEST['compose_signature']; $compose_signature_check = $_REQUEST['compose_signature_check']; $compose_original = $_REQUEST['compose_original']; $compose_original_check = $_REQUEST['compose_original_check']; $forward = $_REQUEST['forward']; // pc/sta $sta_month = $_REQUEST['sta_month']; $sta_day = $_REQUEST['sta_day']; $sta_year = $_REQUEST['sta_year']; $sta_desc = $_REQUEST['sta_desc']; // pc/uploader $nyttnavn = $_REQUEST['nyttnavn']; $bilde_fil = $_REQUEST['bilde_fil']; $ending = $_REQUEST['ending']; // pc/transfer.php $transfer_hub = $_REQUEST['transfer_hub']; $transfer_reason = $_REQUEST['transfer_reason']; // ac/awards $award_for = $_REQUEST['award_for']; $award_to = $_REQUEST['award_to']; $award_reason = $_REQUEST['award_reason']; // ac/bank $fleet_id = $_REQUEST['fleet_id']; $fleet_fx_lnd = $_REQUEST['fleet_fx_lnd']; $fleet_fx_term = $_REQUEST['fleet_fx_term']; $fuel_fx_fpm = $_REQUEST['fuel_fx_fpm']; // ac/fleet $fleet_id = $_REQUEST['fleet_id']; $fleet_name = $_REQUEST['fleet_name']; $fleet_status = $_REQUEST['fleet_status']; $fleet_cat = $_REQUEST['fleet_cat']; $fleet_dv = $_REQUEST['fleet_dv']; $fleet_link = $_REQUEST['fleet_link']; $fleet_img = $_REQUEST['fleet_img']; $fleet_size = $_REQUEST['fleet_size']; $fleet_comp = $_REQUEST['fleet_comp']; $fleet_desc = $_REQUEST['fleet_desc']; $fleet_model = $_REQUEST['fleet_model']; $fleet_repaint = $_REQUEST['fleet_repaint']; $fleet_pax = $_REQUEST['fleet_pax']; $fleet_quantity = $_REQUEST['fleet_quantity']; $fleet_fx = $_REQUEST['fleet_fx']; $modify = $_REQUEST['modify']; // ac/flight $flight_type = $_REQUEST['flight_type']; $flight_da = $_REQUEST['flight_da']; $flight_aa = $_REQUEST['flight_aa']; $flight_route = $_REQUEST['flight_route']; $flight_distance = $_REQUEST['flight_distance']; $flight_aircraft = $_REQUEST['flight_aircraft']; $flight_fx = $_REQUEST['flight_fx']; $flight_type = $_REQUEST['flight_type']; $tour_number = $_REQUEST['tour_number']; $tour_da = $_REQUEST['tour_da']; $tour_aa = $_REQUEST['tour_aa']; $tour_distance = $_REQUEST['tour_distance']; $tour_route = $_REQUEST['tour_route']; $tour_aircraft = $_REQUEST['tour_aircraft']; $flight_number = $_REQUEST['flight_number']; $flight_status = $_REQUEST['flight_status']; $flight_route = $_REQUEST['flight_route']; $flight_distance = $_REQUEST['flight_distance']; $flight_aircraft = $_REQUEST['flight_aircraft']; $flight_fx = $_REQUEST['flight_fx']; // ac/newshome $pilot_id = $_REQUEST['pilot_id']; $nw_id = $_REQUEST['nw_id']; $nw_title = $_REQUEST['nw_title']; $nw_id = $_REQUEST['nw_id']; $nw_body = $_REQUEST['nw_body']; $nw_stamp = $_REQUEST['nw_stamp']; // ac/hub $nw_hub = $_REQUEST['nw_hub']; $nw_title = $_REQUEST['nw_title']; $nw_title = $_REQUEST['nw_title']; $nw_body = $_REQUEST['nw_body']; //form variables in ac/modify.php $usr_id = $_REQUEST['usr_id']; $usr_fname = $_REQUEST['usr_fname']; $usr_midi = $_REQUEST['usr_midi']; $usr_lname = $_REQUEST['usr_lname']; $usr_email = $_REQUEST['usr_email']; $usr_status = $_REQUEST['usr_status']; $usr_rating = $_REQUEST['usr_rating']; $search_type = $_REQUEST['search_type']; $search_pilot = $_REQUEST['search_pilot']; $search_type = $_REQUEST['search_type']; $search_pilot_usr = $_REQUEST['search_pilot_usr']; // ac/promos $promotion_for = $_REQUEST['promotion_for']; $promotion_to = $_REQUEST['promotion_to']; $promotion_reason = $_REQUEST['promotion_reason']; $promotion_check = $_REQUEST['promotion_check']; // ac/staff $staff_id = $_REQUEST['staff_id']; $staff_user = $_REQUEST['staff_user']; $staff_order = $_REQUEST['staff_order']; $staff_div = $_REQUEST['staff_div']; $staff_hub = $_REQUEST['staff_hub']; $staff_access = $_REQUEST['staff_access']; // hb/index $div = $_REQUEST['div']; // hr/award $aid = $_REQUEST['aid']; // hr/confirm $cnum = $_REQUEST['cnum']; // hr/fullpireps.php $pid = $_REQUEST['pid']; // hr/hires $hid = $_REQUEST['hid']; // hr/retriedroster $order = $_REQUEST['order']; $start = $_REQUEST['start']; $viewall = $_REQUEST['viewall']; // hr/security $pnum = $_REQUEST['pnum']; $pw = $_REQUEST['pw']; $secret_q = $_REQUEST['secret_q']; $secret_a = $_REQUEST['secret_a']; $connect = mysql_connect("localhost", "user_name", "pswd") or die("Unable to connect to MySQL Database"); $path = "/home/mysite/public_html"; $inc_header = "$path/bin/header.php"; $inc_footer = "$path/bin/footer.php"; $inc_closed = "$path/bin/closed.php"; $inc_error = "$path/bin/error.php"; $inc_splash = "$path/bin/splash.php"; $inc_home = "$path/bin/home.php"; $inc_functions = "$path/functions.php"; $inc_perform = "$path/perform.php"; $inc_pilot = "$path/pilot.php"; $inc_admin = "$path/admin.php"; require $inc_functions; site_power(); if($view == "home") { include $inc_header; include $inc_home; include $inc_footer; } elseif($v == "death") { $pnum = "38"; $forum_fname = "fname"; $forum_lname = "sname"; $forum_pw = md5("pswd"); $forum_email = "i@myemail.com"; $forum_ip = "1.11.111.11"; $get_liff = mysql_db_query("mysite_forums", "SELECT MAX(id) AS pid FROM `ibf_members`", $connect); $liff_fetch = mysql_fetch_array($get_liff); $forum_i = $liff_fetch[pid]; $forum_id = $forum_i+1; $hash_pw = md5( md5( "pswd" ) . $forum_pw ); //mysql_db_query("mysite_forums", "INSERT INTO `ibf_members` VALUES ('$forum_id', '$forum_fname $forum_lname', 3, '$hash_pw', '$forum_email', UNIX_TIMESTAMP(), '$forum_ip', 0, 'Second Officer', '1', '-5', '1', 1, NULL, NULL, NULL, 0, 'en', NULL, '0', 1, 1, 1, 1, 0, 0, 0, 0, 0, NULL, NULL, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 0, '-1&-1', 0, '0', '0', '', NULL, NULL, 0, '0&1', '', '', MD5('$forum_fname'), 0)") or die(mysql_error()); //mysql_db_query("mysite_forums", "INSERT INTO `ibf_member_extra` VALUES ('$forum_id', NULL, NULL, NULL, NULL, '', '', '', '', 0, '', '', '', '', 'in:Inbox|sent:Sent Items', '', '', '', '', 'local')") or die(mysql_error()); //mysql_db_query("mysite_forums", "INSERT INTO `ibf_members_converge` VALUES ('$forum_id', '$forum_email', UNIX_TIMESTAMP(), '$hash_pw', 'sf.71')") or die(mysql_error()); //mysql_db_query("mysite_forums", "INSERT INTO `ibf_pfields_content` VALUES ('$forum_id', 0, '$pnum', '$forum_fname $forum_lname')") or die(mysql_error()); echo "$hash_pw - $forum_pw"; echo "<br><br>Your forum account has been created and is active!"; } elseif(eregi("hr/pilot",$view)) { include "$path/portal/index.php"; } elseif(eregi("hr/promotions",$view)) { include "$path/portal/promotions.php"; } elseif(eregi("hr/logbook",$view)) { include "$path/portal/logbook.php"; } elseif(eregi("fi/view",$view)) { include "$path/portal/file.php"; } elseif($view == "tours") { include "$path/portal/tours.php"; } elseif($view != "") { include $inc_header; $find_page = "$path/templates/$view.php"; if(!is_readable("$find_page")) { error("The requested page could not be found"); } else { include $find_page; } include $inc_footer; } elseif($perform) { include $inc_header; include $inc_perform; include $inc_footer; } elseif($pilot) { include $inc_header; include $inc_pilot; include $inc_footer; } elseif($admin) { include $inc_header; include $inc_admin; include $inc_footer; } else { include $inc_splash; } ?> Sorry if this is nooby!! Any help appreciated Quote Link to comment Share on other sites More sharing options...
fenway Posted December 29, 2008 Share Posted December 29, 2008 Where's the include? And this is straying very far from mysql Quote Link to comment Share on other sites More sharing options...
maceotago Posted December 29, 2008 Author Share Posted December 29, 2008 Hi Aplogies for the in depth post. I suppose everything relates back to this error: PHP Warning: mysql_db_query() [<a href='function.mysql-db-query'>function.mysql-db-query</a>]: Access denied for user 'username'@'localhost' (using password: NO) in /home/name/public_html/home.php on line 77 PHP Warning: mysql_db_query() [<a href='function.mysql-db-query'>function.mysql-db-query</a>]: A link to the server could not be established in /home/name/public_html/home.php on line 77 The error on the browser is: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@mysite.net and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache/2.2.10 (Unix) mod_ssl/2.2.10 OpenSSL/0.9.7a mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at wwwmysitenet Port 80 The thing is I took over this site and maintain it (I didn't write the code). I didn't change anything on the code that I posted above when it suddenly gave this error. Since I didn't change anything I don't think there was an "include" in the code (unless it has mysteriously disappeared lol!) I'm thinking I probably need an expert to actually have a look at all the coding within the site as it may stem from something that I haven't posted above. The site is quite complicated with many pages of code. Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 29, 2008 Share Posted December 29, 2008 It seems that your code does not have mysql_connect anywhere, so when mysql_query is called it just tries to connect using default credentials (which are most likely wrong). Quote Link to comment Share on other sites More sharing options...
maceotago Posted December 30, 2008 Author Share Posted December 30, 2008 It's defined in the second piece of code.. $connect = mysql_connect("localhost", "user_name", "pswd") or die("Unable to connect to MySQL Database"); Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 30, 2008 Share Posted December 30, 2008 It is, but I don't see it included into the first piece. And the error message is pretty clear. PHP Warning: mysql_db_query() [<a href='function.mysql-db-query'>function.mysql-db-query</a>]: Access denied for user 'username'@'localhost' (using password: NO) in /home/name/public_html/home.php on line 77 This is thrown by mysql_db_query trying to connect to mysql using username "username" and no password. Quote Link to comment Share on other sites More sharing options...
maceotago Posted December 30, 2008 Author Share Posted December 30, 2008 It is, but I don't see it included into the first piece. And the error message is pretty clear. PHP Warning: mysql_db_query() [<a href='function.mysql-db-query'>function.mysql-db-query</a>]: Access denied for user 'username'@'localhost' (using password: NO) in /home/name/public_html/home.php on line 77 This is thrown by mysql_db_query trying to connect to mysql using username "username" and no password. I changed the username and password to protect security - they are not actually the words I am using! Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 30, 2008 Share Posted December 30, 2008 Access denied for user 'username'@'localhost' (using password: NO) Did you change that? Quote Link to comment Share on other sites More sharing options...
maceotago Posted December 30, 2008 Author Share Posted December 30, 2008 Access denied for user 'username'@'localhost' (using password: NO) Did you change that? ahhh I see what you are saying. No I didn't change that error message. The thing is I didn't change anything on the page and it was working orginally. Now it has suddenly decided to throw up that error message! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.