PHP - Url Incorrect On Php Includes
Hi all
My site is build using php includes. the index.php file contains code like <?php if(@$_GET['page'] == "web-design"){ include("includes/web-design.php"); } else if(@$_GET['page'] == "hosting"){ include("includes/hosting.php"); } else { include("includes/home.php"); } ?> I have created a sub domain blog.maplewebdesign.co.uk and a sub dircetory named blog. The link to this part of my site doesn't use includes, I want it to link directly to that sub directories index.php page. This works fine, but then when I click on a different link anywhere on the site my url is as follows www.maplewebdesign.co.uk/blog/index.php?page=home For some reason it is keeping the blog/ in the URL If you want to see go to http://www.maplewebdesign.co.uk/blog/ then click on a differnt link and check out the URL What am I doing wrong? Thanks Adi Similar Tutorialshow to get the domain name of a website which includes my includes file. The code would need to be put within my includes file so when any site includes it the file will get the sites domain. to $currentDomain i have tried using: echo file_get_contents() instead of includes but i get the same issue I get back the includes domain. then code i have tried (in the includes file): Code: [Select] $curdomain1= $_SERVER['HTTP_HOST']; $pageUR1 = ereg_replace("/(.+)", "", $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); $curdomain2 = str_replace("www.", "", $pageUR1); echo "<br> 1# Current Domain: ".$curdomain1; echo "<br> 2# Current Domain: ".$curdomain2; Ever since I switched over to pagination, the ranks for the sites have been off. I use to have an $i++ increment that kept the ranks, but now with pagination, it just ranks those on the current page. Is there a way to bypass this? public function grabSites() { //amount of sites $amount = mysql_num_rows(mysql_query("SELECT * FROM sites")); if($amount > 0) { //amount per page $p_page = 13; //track page $start = $_GET['page']; //max_pages $max_pages = $amount / $p_page; //set default if(!$start) $start = 0; //new query $query = mysql_query("SELECT id,title,description,votes,date,outl,site_url FROM sites ORDER BY votes DESC LIMIT $start, $p_page"); while($fetch = mysql_fetch_assoc($query)) { ++$i; $i = $i + $p_page; echo " <div id='post-1' class='post'> <h2 class='title'><font color='white'>#". $i." ".$fetch['title'] ."</font></h2> <div class='entry'> <b>". $fetch['title'] ." currently has ". $fetch['votes'] ." votes. <a href='vote.php?id=". $fetch['id'] ."'>Vote now</a>.</b> <br/><br/> <p>". nl2br(stripslashes($fetch['description'])) ."</p> </div> <p class='meta'><a href='". $fetch['site_url'] ."'>Visit</a></p> </div> "; } //set back and forth variables $previous = $start - $p_page; $next = $start + $p_page; ?> <hr> <center> <?php if(!($start<=0)) echo "<a href='index.php?page=". $previous ."'><<</a>"; $i = 1; for($x = 0; $x < $amount; $x = $x + $p_page) { echo "<a href='index.php?page=". $x ."'> ". $i ." </a>"; $i++; } if(!($start>=$amount-$p_page)) echo "<a href='index.php?page=". $next ."'>>></a></center>"; ?> </center> <?php } else { echo " <div id='post-1' class='post'> <h2 class='title'><a href='#'>Oh NOEZ!</a></h2> <h3 class='date'>". date("M-d-Y") ."</h3> <div class='entry'> <p>There are currently no sites to display!</p> </div> <p class='meta'>View</p> </div> "; } } The password ARE correct. My code keeps saying that the password is INCORRECT. The password is MD5'ed once a user registers, and when they type in a password at the login (as shown), the password is also MD5'ed. Why is it that it's output is incorrect password? <?php session_start(); include("includes/mysql.php"); include("includes/config.php"); ?> <title><?php echo $title; ?></title> <?php if(!$_SESSION['user']) { $username = $_POST['username']; $password = $_POST['password']; $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); if(!$password || !$username) { echo ' <h1>Login</h1> <center><p><form action="login.php" method="POST"> <table border="0"> <tr><th>Username:</th> <td><input type="text" name="username" maxlength="20"><br/></td></tr> <tr><th>Password:</th> <td><input type="password" name="password" maxlength="30"><br/></td></tr> <tr><th></th><td><input type="submit" value="Login"></td></tr> </table></form></p></center> </div> '; } else { $query = mysql_query("SELECT COUNT(username),password,username FROM users WHERE username='$username'"); $check = mysql_fetch_assoc($query); $db_username = $check['username']; $password = md5($password); if($check['COUNT(username)'] < 1) { echo ' <p>No account exists with this username. Please go back.</p> '; } elseif($check['password']==$password && $db_username==$username) { echo ' <h1>Login Successful</h1> <p>You have successfully logged in! Return home.</p> '; $_SESSION['user']=$username; } else { echo ' <p>The password you have enetered in is incorrect. Please go back.</p> '; } } } else { echo ' <p>Your already logged in!</p> '; } ?> It's been a while since I've used my queries, can anyone tell me what's wrong with this mysql query? Code: [Select] $query = mysql_query("SELECT * FROM `chicken_names` WHERE `gender` = 'Hen' AND `name` LIKE '%$s_terms%' ORDER BY `likes` DESC") or die(mysql_error()); I have a small bit of jquery code that is not working:
$(function() { $(‘’[name=\'pet_type\']”).change(function() { $(‘’[name=\'breed\']”).removeAttr(‘disabled’); $(‘’[name=\'breed\']”).children(‘data-pet-type[name!=\'’ + $(this).val() + ‘\']’).hide(); $(‘’[name=\'breed\']”).children(‘data-pet-type[name=\'’ + $(this).val() + ‘\']’).show(); }); });My javascript is not good at all, so cannot spot errors? Any help would be much appreciated! Thanks I have a register page that MD5 Hash's the users password and a login which also does this. However, no matter what I try it always says incorrect password. Even when I remove the MD5. Register Code: Code: [Select] <?php error_reporting (E_ALL ^ E_NOTICE); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Member System - Register</title> </head> <body> <?php if ( $_POST['registerbtn'] ){ $getuser = $_POST['user']; $getemail = $_POST['email']; $getpass = $_POST['pass']; $getretypepass = $_POST['retypepass']; if ($getuser){ if ($getemail){ if ($getpass){ if ($getretypepass){ if ( $getpass === $getretypepass ){ if ( (strlen($getemail) >= 7) && (strstr($getemail, "@")) && (strstr($getemail, ".")) ){ require("./connect.php"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 0){ $query = mysql_query("SELECT * FROM users WHERE email='$getemail'"); $numrows = mysql_num_rows($query); if ($numrows == 0){ $password = md5(md5("kjfiufj".$password."Fj56fj")); $date = date("F d, Y"); $code = md5(rand()); mysql_query("INSERT INTO users VALUES ( '', '$getuser', '$password', '$getemail', '0', '$code', '$date' )"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 1){ $site = "http://c3221281.web44.net/"; $webmaster = "Simon <admin@simon.com>"; $headers = "From: $webmaster"; $subject = "Activate Your Account"; $message = "Thanks for registering. Click the link below to activate your account.\n"; $message .= "$site/activate.php?user=$getuser&code=$code\n"; $message .= "You must activate your account to login."; if ( mail($getemail, $subject, $message, $headers) ){ $errormsg = "You have been registered. You must activate your account from the activation link sent to <b>$getemail</b>."; $getuser = ""; $getemail = ""; } else $errormsg = "An error has occueed. Your activation email was not sent."; } else $errormsg = "An error has occured. Your account was not created."; } else $errormsg = "There is already a user with that email."; } else $errormsg = "There is already a user with that username."; mysql_close(); } else $errormsg = "You must enter a valid email address to register."; } else $errormsg = "Your passwords did not match."; } else $errormsg = "You must retype your password to register."; } else $errormsg = "You must enter your password to register."; } else $errrosmg = "You must enter your email to register."; } else $errormsg = "You must enter your username to register."; } $form = "<form action='./register.php' method='post'> <table> <tr> <td></td> <td><font color='red'>$errormsg</font></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='user' value='$getuser' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email' value='$getemail' /></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='pass' value='' /></td> </tr> <tr> <td>Retype:</td> <td><input type='password' name='retypepass' value='' /></td> </tr> <tr> <td></td> <td><input type='submit' name='registerbtn' value='Register' /></td> </tr> </table> </form>"; echo $form; ?> </body> </html> Login Code: Code: [Select] <?php error_reporting (E_ALL ^ E_NOTICE); session_start(); $userid = $_SESSION['userid']; $username = $_SESSION['username']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Member System - Login</title> </head> <body> <?php if ($username && $userid){ echo "You are already logged in as <b>$username</b>. <a href='./member.php'>Click here</a> to go to the member page."; } else{ $form = "<form action='./login.php' method='post'> <table> <tr> <td>Username:</td> <td><input type='text' name='user' /></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password' /></td> </tr> <tr> <td></td> <td><input type='submit' name='loginbtn' value='Login' /></td> </tr> <tr> <td><a href='./register.php'>Register</a></td> <td><a href='./forgotpass.php'>Forgot your password?</a></td> </tr> </table> </form>"; if ($_POST['loginbtn']){ $user = $_POST['user']; $password = $_POST['password']; if ($user){ if ($password){ require("connect.php"); $password = md5(md5("kjfiufj".$password."Fj56fj")); // make sure login info correct $query = mysql_query("SELECT * FROM users WHERE username='$user'"); $numrows = mysql_num_rows($query); if ($numrows == 1){ $row = mysql_fetch_assoc($query); $dbid = $row['id']; $dbuser = $row['username']; $dbpass = $row['password']; $dbactive = $row['active']; if ($password == $dbpass){ if ($dbactive == 1){ // set session info $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; echo "You have been logged in as <b>$dbuser</b>. <a href='./member.php'>Click here</a> to go to the member page."; } else echo "You must activate your account to login. $form"; } else echo "You did not enter the correct password. $form"; } else echo "The username you entered was not found. $form"; mysql_close(); } else echo "You must enter your password. $form"; } else echo "You must enter your username. $form"; } else echo $form; } ?> </body> </html> Many thanks for your time and help, hello in the attached code, how do i add another field to the query? ie, i have all the code to create the result and would like to add further values such as $dept? what is the correct way to code query? i must stress that i am using php 4.4.7 so json_encode is out. the code is working but just need to find a way to add the $dept to the qeury? many thanks $dept = array(); $box = array(); while ($row = mysql_fetch_array($result)) { $dept[] = $row['department']; $box[] = $row['custref']; } /*$items = rtrim($_POST['items'],","); $sql = "UPDATE `boxes` SET status = 'Out' WHERE Id IN ($items)"; $result = runSQL($sql);*/ $total = count(explode(",",$items)); $result = runSQL($sql); $total = mysql_affected_rows(); /// Line 18/19 commented for demo purposes. The MySQL query is not executed in this case. When line 18 and 19 are uncommented, the MySQL query will be executed. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); header("Cache-Control: no-cache, must-revalidate" ); header("Pragma: no-cache" ); header("Content-type: text/x-json"); $json = ""; $json .= "{\n"; $json .= "box: [\"". implode('","', $box) ."\"]\n"; $json .= "}\n"; echo $json; $sql = "INSERT INTO `act` (`item`) VALUES ('". implode("'),('", $box) . "')"; $result = runSQL($sql); So I am trying to make an incorrect password message but the message never appears.
My code:
<? require "./includes/config.php"; $LS->init(); if(isset($_POST['act_login'])){ $user=$_POST['login']; $pass=$_POST['pass']; if($user=="" || $pass==""){ $msg=array("Error", "Username / Password Wrong !"); } else { if(!$LS->login($user, $pass)){ $msg=array("Error", "Username / Password Wrong !"); } } } ?> i am writing this script for use as an include in joomla and the directphp plugin so in my joomla article i have: Code: [Select] <?php include 'test/conducttest.php'; conducttest(); ?> Ok now my issue! the form in this function is passing only the values for the last item in the loop rather than for the selected radio item when submitted. so when say for example the radio selected is: ID TEST TYPE UNIQUE TEST ID AVAILABLE 5 Adolescent Clinical 50021629 1 and the last item in the list is: ID TEST TYPE UNIQUE TEST ID AVAILABLE 4 Adult Clinical 12341629 1 When the form is submitted even if the 1st item is selected, it returns the value for the second one. I am sorta new to php so any suggestions will be appreciated. Here is my full code: Code: [Select] <?php function conducttest() { //GET JOOMLA USER ID & USERNAME FOR LOGGED USER $user =& JFactory::getUser(); $userID = $user->id; //GET JOOMLA DATABASE OBJECTS $db =& JFactory::getDBO(); //NEW TESTS QUERY (what purchased test are available for use with 'item_available' == '1' {unused test} and matching current 'user_id') $new_query = " SELECT * FROM crt_transactionHistory WHERE user_id = ".$userID." AND item_available = '1' ORDER BY item_name, id "; $db->setQuery($new_query); $new = $db->loadAssocList(); //OPEN TESTS QUERY (what purchased test are available for use with 'item_available' == '2' {resume test} and matching current 'user_id') $resume_query = " SELECT * FROM crt_transactionHistory WHERE user_id = ".$userID." AND item_available = '2' ORDER BY item_name, id "; $db->setQuery($resume_query); $resume = $db->loadAssocList(); //DISPLAY use_test FORM if(!isset($_POST['test'])) { //SELECT FORM: WHICH TEST WOULD YOU LIKE TO USE? echo ' <fieldset> <table> <form method="post" action="'.$PHP_SELF.'">'; if (empty($new)) { echo ' <th colspan="3"align="left">NO NEW TESTS AVAILABLE</th>'; } else { echo ' <th colspan="3"align="left">NEW TESTS AVAILABLE</th> <tr> <td width="75px">SELECT</td> <td width="50px">ID</td> <td width="150px">TEST TYPE</td> <td width="150px">UNIQUE TEST ID</td> <tr>'; foreach ($new as $result1) { echo ' <tr> <td><input type="radio" value="' .$result1['id']. '" name="test_id"></td> <td>'.$result1['id'].'</td> <td><input type="hidden" value="'.$result1['item_name'].'" name="item_name">'.$result1['item_name'].'</td> <td><input type="hidden" value="'.$result1['item_number'].'" name="item_number">'.$result1['item_number'].'</td> <input type="hidden" value="'.$result1['item_available'].'" name="item_available"> <input type="hidden" value="'.$userID.'" name="userID"> <tr>'; } } echo ' </table> <hr /> <table>'; if (empty($resume)) { echo ' <th colspan="3"align="left">NO TESTS TO RESUME</th>'; } else { echo ' <th colspan="3"align="left">RESUME TEST</th> <tr> <td width="75px">SELECT</td> <td width="50px">ID</td> <td width="150px">TEST TYPE</td> <td width="150px">UNIQUE TEST ID</td> <tr>'; foreach ($resume as $result2) { echo ' <tr> <td><input type="radio" value="' .$result2['id']. '" name="test_id"></td> <td>'.$result2['id'].'</td> <td><input type="hidden" value="'.$result2['item_name'].'" name="item_name">'.$result2['item_name'].'</td> <td><input type="hidden" value="'.$result2['item_number'].'" name="item_number">'.$result2['item_number'].'</td> <input type="hidden" value="'.$result2['item_available'].'" name="item_available"> <input type="hidden" value="'.$userID.'" name="userID"> <tr>'; } } echo ' </table> </fieldset> <input type="submit" name="test" value="Conduct Test" /> </form> '; } //NOW A TEST HAS BEEN SELECTED FOR USE if(isset($_POST['test'])) { $test_id = $_POST['test_id']; $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $item_available = $_POST['item_available']; $userID = $_POST['userID']; echo $test_id.'<br />'; echo $item_name.'<br />'; echo $item_number.'<br />'; echo $item_available.'<br />'; echo $userID.'<br />'; //IF THIS IS A NEW TEST... if ($item_available == "1") { echo 'new test'; } //IF WE ARE RESUMING A TEST... elseif ($item_available == "2") { echo 'resume test'; } } } ?> Currently I have 5 entries in my table. Entring this query displays all five in the correct order. Code: [Select] SELECT * FROM products ORDER BY count DESC LIMIT 16 However, using this code, the first result is omitted and the last four are displayed. $query="SELECT * FROM products ORDER BY count DESC LIMIT 16"; $result = mysql_query($query); $row = mysql_fetch_array($result); echo '<div>'; while ($row = mysql_fetch_array($result)) { echo '<div>'.$row[product].'</div> <div>'.$row[count].'</div>'; } echo '</div>'; Can someone help me find my error? Thanks Hello folks, I've got a problem with a search script. It's searching a db containing various properties (as in buildings) and it's not quite returning the correct results. The search form asks that you select a house type (4 options, all of which are tick boxes) and then the last part of the form is select how many bedrooms you'd like (which is a drop-down list featuring numbers 2-5) What should happen is someone selects one or more of the tick boxes and then the number of bedrooms and it returns all the house types that were ticked but only those with the number of bedrooms that were specified in the original search. Currently the results are correct in that they're showing the correct house types, but the number of bedrooms isn't right. e.g. if you chose 2 bedrooms in the search it shows those, as well as 3, 4 and 5 bedrooms in the results. Can't figure it out but it will be something to do with && and OR in my search script. Can anyone suggest a tweak to this that might work? (I'm using the $_GET function because the search form is in a Flash movie) $Result = mysql_query("select * from property_names where TownHouse = '$_GET[TownHouse]' OR Apartment = '$_GET[Apartment]' OR Detached = '$_GET[Detached]' OR SemiDetached = '$_GET[SemiDetached]' && visible= 'Yes' && bedrooms = '$_GET[Bedrooms]' && bedrooms = '$_GET[Bedrooms]'") Incorrect login attempt 1 \/ Incorrect login attempt 2 \/ Incorrect login attempt 3 -->> ?forgot your login details? What's the most effecient way of achieving this? Is it to: 1. create a session for the user who hasn't logged in 2. the user login fails once, session['fail']=1 3. the user login fails twice, session['fail']=2 4. the user login fails for a third time pushing the session['fail'] count to three: this triggers an 'if' on the index.php prompting the user to retrieve their details through the "forgot login details system" However if the session['fail'] count never reaches 3 then this temp session is destroyed and the proper one created allowing the user into the site?? As usual any pointers into the correct direction here would be very much appreciated (and i try to repay by answering other peoples questions [where i can ]) this is the query: $query = "INSERT INTO kamerleden VALUES ('', '$twitter_id', '$name', '$nickname', '$fraction', '$residence', '$age', '$gender', '', '', '', '')"; it used to work but i switched to a different hosting. The first '' is the id which gives this error: query failed: Incorrect integer value: '' for column 'id' at row 1 in the database id is a int, with a length of 2 and with auto increment. How can i fix it? As expected when a die statement is triggered, my script is exited and ALL of the fields that have been filled in on my form are wiped clean. This however is proving to be annoying for users making mistakes. Is there a way to keep the data in the correctly filled in fields, and to just wipe or highlight the incorrectly filled in fields? Code: [Select] <?php function checkPostcode (&$toCheck) { $alpha1 = "[abcdefghijklmnoprstuwyz]"; $alpha2 = "[abcdefghklmnopqrstuvwxy]"; $alpha3 = "[abcdefghjkstuw]"; $alpha4 = "[abehmnprvwxy]"; $alpha5 = "[abdefghjlnpqrstuwxyz]"; $pcexp[0] = '^('.$alpha1.'{1}'.$alpha2.'{0,1}[0-9]{1,2})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[1] = '^('.$alpha1.'{1}[0-9]{1}'.$alpha3.'{1})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[2] = '^('.$alpha1.'{1}'.$alpha2.'[0-9]{1}'.$alpha4.')([0-9]{1}'.$alpha5.'{2})$'; $pcexp[3] = '^(gir)(0aa)$'; $pcexp[4] = '^(bfpo)([0-9]{1,4})$'; $pcexp[5] = '^(bfpo)(c\/o[0-9]{1,3})$'; $Postcode = strtolower($toCheck); $Postcode = str_replace (' ', '', $Postcode); $valid = false; foreach ($pcexp as $regexp) { if (ereg($regexp,$Postcode, $matches)) { $toCheck = strtoupper ($matches[1] . ' ' . $matches [2]); $toCheck = ereg_replace ('C\/O', 'c/o ', $toCheck); $valid = true; break; } } if ($valid){return true;} else {return false;}; } if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '') { die ("<div class=\"form\">You did not complete the name field, please try again</div>"); } elseif ($Phone == '' or (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $Phone))) { die("<div class=\"form\"> You completed the telephone field incorrectly, please try again</div>"); } elseif ($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL))) { die("<div class=\"form\"> You completed the Email field incorrectly, please try again</div>"); } elseif ($Postcode == '' or (!checkPostcode($Postcode))) { die("<div class=\"form\"> You did not complete the Postcode field correctly, please try again</div>"); } elseif ($Website == '' or (!preg_match("~^[a-z0-9.-]+\.(com|org|net|edu|co.uk)~i", $Website))) { die("<div class=\"form\">You completed the website field incorrectly, please try again</div>"); } else { echo("<div id=\"formtwo\">Thankyou for submiting your details, you will be added to our directory shortly</div>"); } $query = ("INSERT INTO business (`id`, `Name`, `Type`, `Subtype`, `Phone`, `Email`, `Postcode`, `WebAddress`, `Confirmed`) VALUES ('NULL', '$Name', '$drop', '$tier_two' , '$Phone', '$Email', '$Postcode', '$Website', 'Yes')"); mysql_query($query) or die ( "<br>Query: $query<br>Error: " .mysql_error()); } ?> I have the following query: $getVideos = mysql_query("SELECT catergory, COUNT(catergory) as 'catCount' FROM videos GROUP BY catergory"); Using this in PHPMyAdmin returns the correct results of: catergory | catCount 0 | 7 1 | 1 10 | 2 How would get those results into a PHP array or what not...I have done this before but along time ago and cannot for the life of me remember how to do it. Hopefully someone can point me in the right direction? Regards, PaulRyan. Sorry for the long message but I need HELP!!! I'm somewhat familiar with HTML but very little in PHP, and even less in CSS. My eCommerce program is PHP based so I've had to learn to work with it. I did have someone else initially setup and create my website but over the past few years have taken it further myself. I've fiddled with some of it and looked up how to do certain things, such as have only one header and/or sidebar I can use for all pages. I use Dreamweaver CS4 and FTP with FileZilla. But I'm still new at this and have run into a couple of issues.
My webhost is GoDaddy, my website is MikiCat Designs and after fiddling for months, in March finally got my site to where I liked it. Unfortunately, I haven't kept it up. Anyway, I went there a couple of weeks ago and found that the PHP includes I'd had in the HTML files were no longer working. I get the error [an error occurred while processing this directive]. Weird. Worked fine before, now it doesn't. Called GoDaddy who says they didn't do anything . Uh huh. Now I know I didn't do anything since I haven't updated the site in 4 months! So, what could have caused this problem? I've had no idea how to fix it other than to change the index.html to index.php and, of course, do a minor repair on the include. Works fine and my header.php and leftsidebar.php show up again. Yay! Herein lies another problem. My header and sidebar link to other files some of which were HTML files. But those HTML files had the same header and sidebar issues as my INDEX file. This had to be fixed so I changed them to PHP. Still working on the changes. I deleted most of the HTML files from the server. So the links in my header and lefsidebar files now point to PHP files. e.g., gallery.html to gallery.php. When called on it's own, gallery.php shows up perfectly. But, no matter what I do, the header file still tries to load the HTML file!!! It's driving me crazy. What have I done wrong? I've deleted them both, refreshed, cleared cache and uploaded them again but I still get the same error. If you click on Gallery in the header, it tries to link gallery.html not gallery.php! Funny thing is, the leftsidebar now works perfectly and points to the proper PHP files. I'm completely confused now. I don't know why my header is insisting on trying to load the HTML page instead of the PHP. But here's my header code. Lines 41 and 42 work, lines 43, 44 and 45 do not. * Quietly banging head against wall while awaiting help. <html> <body> <!-- begin #header --> <!-- begin Facebook script --> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <!-- end Facebook script --> <div id="container"> <div id="headerright"> <form method="post" action="search.php"> <input type="hidden" name="posted" value="1"/> <input type="text" name="stext" size="16"/> <input type="submit" name="Search" value="Search"/> </form> </div> <div id="headerright1"> <form method="post" action="cart.php"> <input type="hidden" name="posted" value="1"/> <input type="image" name="Submit" src="images/cartgrn.gif" /> </form></div> <div id="headerright2"> <form method="post" action="clientlogin.php"> <input type="hidden" name="posted" value="2"/> <input type="image" name="Submit" src="images/login2.gif" /> </form> </div> <div id="header"> <div id="PLHIMYFUFUJCDiv" style="position:absolute; left:567px; top:82px; width:490px; z-index:50; white-space:nowrap; direction:ltr;"> <div id="PLHIMYFUFUJCMain" style="width:490px;height:40px"> <ul style="margin:0px;padding:0px;font:italic normal bold 14px Georgia,Times New Roman,Times,serif;"> <li style="float:left;list-style:none;text-align:center;width:98px;height:40px;background-image:url(images/homenav.gif);"><a href="http://www.mikicatdesigns.com" target="_self" title="MikiCat Designs" style="display:block;height:28px;padding:12px 0px 0px 0px;color:#00008b;text-decoration:none;">Home</a></li> <li style="float:left;list-style:none;text-align:center;width:98px;height:40px;background-image:url(images/homenav.gif);"><a href="http://www.mikicatdesigns.com/categories.php" target="_parent" title="Handmade jewelry and accessories " style="display:block;height:28px;padding:12px 0px 0px 0px;color:#00008b;text-decoration:none;">Products</a></li> <li style="float:left;list-style:none;text-align:center;width:98px;height:40px;background-image:url(images/homenav.gif);"><a href="http://www.mikicatdesigns.com/gallery.php" target="_parent" title="Handmade jewelry gallery of past lives" style="display:block;height:28px;padding:12px 0px 0px 0px;color:#00008b;text-decoration:none;">Gallery</a></li> <li style="float:left;list-style:none;text-align:center;width:98px;height:40px;background-image:url(images/homenav.gif);"><a href="http://www.mikicatdesigns.com/aboutmikicatdesigns.php" target="_parent" title="Learn about MikiCat Designs" style="display:block;height:28px;padding:12px 0px 0px 0px;color:#00008b;text-decoration:none;">About Us</a></li> <li style="float:left;list-style:none;text-align:center;width:98px;height:40px;background-image:url(images/homenav.gif);"><a href="http://www.mikicatdesigns.com/contactmikicatdesigns.php" target="_parent" title="Contact MikiCat Designs" style="display:block;height:28px;padding:12px 0px 0px 0px;color:#00008b;text-decoration:none;">Contact Us</a></li> </ul></div><div id="PLHIMYFUFUJCLevel2" style="float:left;width:490px;height:40px;"></div> <script type="text/javascript" src="Pluginlab/Scripts/PLHIM.js">/* PLHIMMenu script ID:PLHIMYFUFUJC */</script> </div> <!-- end #header --> I did some googling and it seems you cannot include a file with an anchor: i.e include "hello.php#foo"; How do you guys go back to the middle of the page of an included file? Do you just not include files with anchors? I wanted to run my entire site inside index.php and just use includes to diplay the appropriate file, but I also need anchors to go to the middle of the page on some of those files. hi This problem is the most strange thing that i seen in the last times. this code works Code: [Select] <?php function conecta () { $host = "localhost"; $senha = "vertrigo"; $login = "xxx"; $database = "emprego"; $conexao = mysql_connect($host,$login,$senha) or die(mysql_error()); mysql_select_db($database,$conexao)or die; } conecta (); //more ?> but this doesn't work Code: [Select] <?php require("includes/f_banco.php"); conecta (); ?> I never seen something like that. Any ideia? the paths are correct, the bd is correct and the query works when i put the function conecta() directly in the php file. Thanks Ok, I am sure this is really simple for all of you, but I have very little experience with php. I haven't sat down to learn php yet, but I will when I have more free time. In the meantime I have the following issue: The site is http://astoryaday.fromyay.com/ I have all the stories in the /stories/ directory, all named 20110504.html, 201105005.html, etc. Every day I write another story, I name it following that pattern, and drop it into the /stories/ folder. I only want the newest story displayed on the page. So I wrote a little script that is: Code: [Select] <?php $files = glob("stories/*.html"); sort($files); $newest = array_pop($files); include($newest); ?> Now, what I want to do, is in the footer, put an Archive that will look like this: -2012 --January ---03 ---02 ---01 -2011 --December ---31 ---30 And upon clicking on the dates, the story from that day will replace the story that is currently included. Any help of how to get this done would be appreciated! Thanks If one file includes another, do I need to start a session in each, or does the included file "inherit" the session? script_1.php // Initialize Session. session_start(); // Require Function require_once('script_2.php'); script_2.php // Initialize Session. session_start(); DO I NEED THIS HERE????????? if ($_SESSION['loggedIn'] == TRUE){ do something } Debbie |