PHP - Problem Loading Website Through Url Vars With New Version Of Php
Code: [Select]
<?php $ACCEPT_FILE['home'] = 'home.html'; $ACCEPT_FILE['general'] = 'general.html'; $ACCEPT_FILE['attorneys'] = 'attorneys.html'; $ACCEPT_FILE['contact'] = 'contact.html'; $ACCEPT_FILE['login'] = 'login.html'; $pagename = $ACCEPT_FILE[$id]; if (!isset($pagename)) $pagename = "home.html"; // default file include( $pagename ); ?> the url looks like: www.yoursite.com/index.php?id=general Ever since i think like php 5 came out i am unnable to load pages it just defaults to the home.html no matter what variable is defined. any ideas or help would be appreciated. Its almost like its not defining the pagename variable until the bottom where $pagename = "home.html". ive been looking at it and reading the manuals for hours and figured its time to make a post. thanks. Similar TutorialsHi, I have uploaded a website for someone but they are having problems viewing it and are telling me that nothing comes up. Not sure if its a dns problem. The domain was registered 2 days ago. Can a couple of you please check and tell me if this site loads up, it should show an ecommerce website : http://www.cassellmotors.com Many thanks, Scott Hi I am attempting to request a single row from a table that has 20 fields. I want to turn each field into it's own variable (you'll see oc1, oc2 etc in the code) and then echo the variable just to check it has worked. When I run the qry below - it picks up the first one correctly but then places the same value in all the other fields. (The $question var should be a long text string but is echoing the first variable instead. There's clearly something wrong with the way I have constructed this - but I don't know at which point it has gone wrong. Can anyone help? $result = mysql_query("SELECT oid,qid,question,posneg,oc1,oc2,oc3,oc4,oc5,oc6,oc7,psc1,psc2,psc3,psc4,psc5,psc6,psc7,psc8,psc9 FROM tblquestions WHERE oid = '1'"); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; } $oid=mysql_result($result,"oid"); $qid=mysql_result($result,"qid"); $question=mysql_result($result,"question"); $posneg=mysql_result($result,"posneg"); $oc1=mysql_result($result,"oc1"); $oc2=mysql_result($result,"oc2"); $oc3=mysql_result($result,"oc3"); $oc4=mysql_result($result,"oc4"); $oc5=mysql_result($result,"oc5"); $oc6=mysql_result($result,"oc6"); $oc7=mysql_result($result,"oc7"); $psc1=mysql_result($result,"psc1"); $psc2=mysql_result($result,"psc2"); $psc3=mysql_result($result,"psc3"); $psc4=mysql_result($result,"psc4"); $psc5=mysql_result($result,"psc5"); $psc6=mysql_result($result,"psc6"); $psc7=mysql_result($result,"psc7"); $psc8=mysql_result($result,"psc8"); $psc9=mysql_result($result,"psc9"); ?> <?php echo $oid; // Question Number?> <?php echo $qid; // Question Number?> <?php echo $question; // Question Number?> <?php echo $posneg; // Question Number?> <?php echo $oc1; // Question Number?> <?php echo $oc2; // Question Number?> <?php echo $oc3; // Question Number?> <?php echo $oc4; // Question Number?> <?php echo $oc5; // Question Number?> <?php echo $oc6; // Question Number?> <?php echo $oc7; // Question Number?> <?php echo $psc1; // Question Number?> <?php echo $psc2; // Question Number?> <?php echo $psc3; // Question Number?> <?php echo $psc4; // Question Number?> <?php echo $psc5; // Question Number?> <?php echo $psc6; // Question Number?> <?php echo $psc7; // Question Number?> <?php echo $psc8; // Question Number?> <?php echo $psc9; // Question Number?> My website www.staceyxsolomon.com is only loading the header of my index.PHP page The full page is there i had double checke in the FTP It happened after my host put me onto another server, all settings carried over, please can somebody advise help if this is PHP related? Hi Everyone, I'm building a custom shopping cart. I'm having trouble getting my code to work on a production server that is running PHP version 5.2.17. My test machine is running version 5.3.0 and the code works just fine. I do not have the ability to upgrade the version of PHP on the production machine. Here is part of my code. If we can fix this, I can fix the other switch cases: //this code adds the item to the cart and creates an array and session variable for the cart. The array is multidimensional (item id1 => quantity, item id2 => quantity, item id3 => quantity and so on...). if (isset($_GET["action"])) { $action = $_GET["action"]; $id = $_GET["id"] ; $q = $_GET["quantity"]; $cart = array(); switch ($action) { case "add": if ($_SESSION["cart"]) { $cart = $_SESSION["cart"]; if (array_key_exists($id,$cart)) { $cart[$id] = $cart[$id] + $q; } else { $cart[$id] = $q; } } else { $cart[$id] = $q; } $_SESSION["cart"] = $cart; break; } } //this code displays the cart array if ($_SESSION["cart"]) { $cart = $_SESSION["cart"]; foreach($cart as $key => $value) { $runQ1 = mysql_query("SELECT * FROM products WHERE id='$key'") or die(mysql_error()); $results = mysql_fetch_array($runQ1); print "<table><tr><td>$results[1]</td><td>$results[2]</td><td>$results[3]</td><td>$results[4]</td></tr></table>"; } } else { print "<table><tr><td>There are no items in your shopping cart.</td></tr></table>"; } The cart session variable is being set but it is only holding one item at a time. If I add a second item to the cart, the 1st item disappears and only the second one is present in the session variable and the table. I'm not sure if it is a session problem or an array problem. Please help before I lose all of my hair! I don't understand why this code works on 5.3.0 and not 5.2.17... Thanks in advance! -Isaac Hi all, But of a PHP newbie so treat me nice but this one is driving me nuts I have the exact same login.php file running on two different servers and they have slightly different versions of PHP installed as follows: 1. PHP Version 5.0.4 - version http://www.trafficpaymaster.com/tpm/phpversion.php 2. PHP Version 5.2.15 - version http://www.dentistsinflorida.org/tpm/phpversion.php The login works fine on the first server from he http://www.trafficpaymaster.com/tpm/login.php Email: test@test.com Pwd: test But try it on the second server he http://www.dentistsinflorida.org/tpm/login.php Using the same email and password (which is correct) it just loops round not letting the user into the main script at index.php Question: Why? What have I got wrong for that later version of PHP? Many thanks guys. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=353342.0 I am a new simplehtmldom user. It is working and the php api loads, and I can parse when I lod data from a string. But if I attemp yo load data from a file like this... Code: [Select] $html->file_get_html("C:\eaahmpg\eatc7402\www\stations\Sydney\code\table_data.txt"); I receive the following error. Fatal error: Call to undefined method simple_html_dom::file_get_html() in... Hmmm. The function IS defined in the api. I'm not sure where I'M going wrong here. eac7402 hi phpfreaks I am trying to remove the get variables from my url. the code below works if I echo it out but to try to modify the $_server variable it will not work. Any ideas? Code: [Select] $current_url = explode('?',$_SERVER["REQUEST_URI"]); $_SERVER["REQUEST_URI"]= $current_url[0]; echo $current_url[0]."<br>"; Trying to pass VARS $URL1 and $type to header location.Heres the code. Code: [Select] $URL1 = $_POST['url']; $type = $_POST['type_request']; session_start(); $string = strtoupper($_SESSION['string']); $userstring = strtoupper($_POST['userstring']); session_destroy(); if (($string == $userstring) && (strlen($string) > 4)) { header("Location: $success"); exit(); The VARS come from a FORM and then go to this script for checkind data. I need to have them continue to the next page. I am inplanting a bonus system to a game i have. I want to say at first that i am not good at php am reading alot and go by learn by doing. But after a few hours i kinda gave up. Here is the code. The page end up blank. And i tested so my syntax work $cost and $points with only the db stuff and this code <div class="yellow_12_bold"><? print (number_format($points)); ?> </div> <div class="yellow_12_bold"><? print (number_format($cost)); ?> </div> And it does. Anyway here is the code Code: [Select] <? $dbq = $db->execute("select * from Bonus where username='$username'"); $points = $dbq->fields['points']; $allpoints = $dbq->fields['points_total']; $dbq->close(); if ($cost == "5" && $amount == "3000") { if ($points == "5" || $points > "5") { $sqlb = "update UserData set turns=turns+'3000' WHERE turns < 50000 and location != '9' and frozen = '0'"; $result1 = mysql_query($sqlb); $sqlc = "update Bonus set points=points-'5' WHERE username = '$username'; $result2 = mysql_query($sqlb); $points2 = ($points - 5); <p align="center" class="black">Thank you! 3000 turns have been added to everyone. You have <div class="yellow_12_bold"><? print (number_format($points)); ?> </div> bonus points left. </p> } else { <p align="center" class="black">Sorry you dont have $cost points. You have <div class="yellow_12_bold"><? print (number_format($points)); ?> </div> bonus points left.</p> } } ?> hey guys i have a static attribute $_exception_handler which is set to Exception and....now this value could change to a customer exception_handler but what i want to do is <?php catch (self::$_exception_handler $e) { } but im getting an error...is there a way of doing this...any help would be greatful thanks class below <?php class Autoloader { protected static $_exception_handler = Exception; protected static $_classes = array(); public static function load_library($class_name) { $file = ROOT . DS. LIBRARY_DIRECTORY . DS . $class_name . CLASS_EXTENSION; try { self::load_class($class_name, $file); } catch (self::$_exception_handler $e) { echo $e->getMessage(); } } public static function load_exception($class_name) { } public static function load_class($class_name, $file) { if (!class_exists($class_name, FALSE)) { if (file_exists($file)) { require_once $file; } else { throw new Exception(sprintf('Class %s not found.', $class_name)); } } } } I want to use all five results separately in order to use in a Jquery slider. Code: [Select] <?php $a = "SELECT * FROM blog_posts ORDER BY id DESC LIMIT 5"; $query = mysql_query($a) or die (mysql_error()); $query_results = mysql_fetch_array($query); ?> I know if i was going to grab vars from an normal array i would just use... Code: [Select] <?php echo $array_reults['0'] ?> Can any one help me with this problem? Hi! I'm working on a simple e-commerce script. I have some $_SESSION variables that is defined and works fine while surfing on the site. But when I close the browser and reenter the site, all the session-variables are not defined (unset?), until i click on a link on the site. Weird behavior... please help! /I Sorry if this isn't the right forum, I wasn't sure where to post this. Alright, so I have a high score submit script, and it goes as follows... This is the actionscript: Code: [Select] on (release) { var usco LoadVars = new LoadVars(); uscore.name = _root.suname; uscore.score = _root.suscore.stime; uscore.game = "alien"; uscore.mode = "survival"; uscore.sendAndLoad("linkhere", uscore, "POST"); play(); } Note: We have also tried: Code: [Select] on (release) { var usco LoadVars = new LoadVars(); uscore.name = _root.suname; uscore.score = _root.suscore.stime; uscore.game = "alien"; uscore.mode = "survival"; var uscoresubmit:LoadVars = new LoadVars(); uscore.sendAndLoad("linkhere", uscoresubmit, "POST"); play(); } The PHP is: <?PHP include('Connect.php'); $name=$_POST['name']; $name=mysql_real_escape_string($name); $score=$_POST['score']; $score=mysql_real_escape_string($score); $game=$_POST['game']; $game=mysql_real_escape_string($game); $mode=$_POST['mode']; $mode=mysql_real_escape_string($mode); if(!empty($game)) { mysql_query("INSERT INTO scores(game, name, score, mode) VALUES ('$game', '$name', '$score', '$mode')"); } ?> I have also tried running a number of things on the "else" of that if(!empty($game)) and nothing has pulled through, so I'm under the notion that it isn't loading the page in sendAndLoad()? It was working before, but it appears to have just stopped, we're not sure what we changed. Any help would be greatly appreciated! Thanks, Xyphon Hi there, Need a little help here if anyone has the time. In short, I have a page that is dynamic, that sends POST data to a handler, pretty standard stuff. Normally, for me anyway, I know what the field names will be in advance and handle then as usual. In this case the form content is created dynamically from a GUI I created and the names of the fields are suffixed with the product ID. Within the handler I have stripped the POST data down to the main two vars, namely the pid- product ID and qty- quantity ordered and within a loop created a string to explode() like; 9_33_21_66 $oStrArray = explode('_', $ostring); echo "ostring[0] =".$oStrArray[0]; echo "ostring[1] =".$oStrArray[1]; echo "ostring[2] =".$oStrArray[2]; echo "ostring[3] =".$oStrArray[3]; Result => ostring[0] =9 ostring[1] =33 ostring[2] =21 ostring[3] =66 Now, the 1st, 3rd, 5th etc will be the pid and the 2nd, 4th, 6th etc. will be the qty. Only two sets are used in this example, normally 50+ pairs of values will be present. If it helps with the loop that I need to create - if a foreach will not suffice - I can deduce how may pairs will be present and send this as a var via GET from the form setting a value for i, for instance. I need to be able to, within a loop, * pull the first value as a pid * run a subroutine to pull the data from the DB table to get all the product info to display on a confirmation page [this is not ecom - just emailed orders for existing clients] I can do all the MySQL Query stuff it is just rationalising the data extracted from the array Well I am sure you can see from that what I am trying to do, I will need to do the multiplications etc. I do not know how to handle the data in the array created by the explode() In logic I would say this if x in $ostring is even then $ostring is a product id [mysql query to get details from table] next item in array is corresponding quantity - print details of product in a table, do the multiplication to give line total and add to $message ready for email - NEXT pair of vars I really hope that makes sense and someone can point me in the right direction - thanks in advance for any assistance. Regards A Hi all If there a better way of setting variables within classes than taking it through the __construct and setting via $this ?? e.g. class SectionsConnect { protected $var; public function __construct($var){ $this->var= $var; } } Can you not set the variable automatically as it comes in through the __construct? Thanks Magnetica Alrite, i have a configs.php that holds a bunch of information (Login info mostly) and when i do $UsrNme = $_POST["user"]; $Passw = $_POST["pass"]; include 'configs.php' if ($UsrNme == $UserName && $Passw == $Password) { setcookie("User", "True", time()+3600); echo "Welcome {$UsrNme}; You have been successfully logged in!"; } else { echo "Sorry, the username {$UsrNme} was not successfully logged in."; } It prints my configs.php instead of using the variables $UserName and $Password to check against UsrNme and Passw... Am i doing something wrong or is this supposed to happen? Hi, In my ErrorDocument I'd like to be able to set some variables for future use then redirect using header() and access them. .htaccess has this entry in it: ErrorDocument 404 /error.php I can pass variables in cookies and all works: setcookie('my_var', 'my_val'); header ("Location: $url"); I would rather set $_SESSION variables but I can't get it to work. session_start(); $_SESSION['my_var'] = 'my_val'; header ("Location: $url"); then... echo $_SESSION['my_var']; returns "". This works fine from other php scripts but not from ErrorDocument. What am I doing wrong here? .htaccess has this in it: ErrorDocument 404 /error.php TIA. Hello, I am having an issue where PHP nulls the donation amount after multiple form submits. Here is a synopsis of what is happening. 1: User enters donation amount and clicks 'submit' 2: Is taken to a confirmation page where they must agree to terms 3: User fails to agree to the terms, the page is reloaded with an error message, and the donation amount is set to null I want to make the donation amount display despite multiple confirm page reloads. How would I do this? Here is the site to test it yourself. Ignore the steamid input and check "do not change my rank upon donation" to test. http://forums.stgdarkrp.org/donate2/check.php Please note: If you use IE, the formatting is messed up, that is a problem I will look into later Hello Guys, I want to be able to filter out any url in any of form $_POST vars? Would I do it with a foreach loop and the preg replace function? I would consider any web address in my form spam. I would like to filter it out.. I'm already using Strip tags, htmlentities, strip_tags, stripslashes & mysql_real_escape_string but they don't seem to filter out URLs.. Thanks for your help in advanced.. |