Sessions Not Returning Anything? - NT - Php4
I use php4 on PWS NT workstation. I use the basic session example in the php docs, the e-commerce tut on devshed and the origional example from devshed(couch sessions) and no luck. I get a page, yet when I view source - nothing after the body tag?
Is there a module I have to uncomment in php.ini or something I have to download? I have tried viewing from another machine and multiple browsers.
View Complete Forum Thread with Replies
Related Forum Messages:
Sessions Without Cookes In Php4
I need to use php sessions without cookies, my session registers works perfect, but I really don't know how to use an expiration time as it is used with cookies. Do you know what can I do to use an expiration time of 15 minutes??. I've tried using mysql to save the session ID's and check there if the sessoin is already registered and how long it has been inactive to see if it's an accepted time, but it really uses a lot of resources just to check. And if you have a lot of visitors at your page your machine almost die. Other thing is that the session Id's keeps saved in my /tmp and are never deleted if you don't do a logout where I use the destroy code.
View Replies !
PHP4+Win98 And Sessions
I've tried PHP4build4, RC1, RC2 and 4.0.0 with Win98 but sessions doesn't work: I've got 2 pages: first_page.php3 <? session_start(); $myvar="test"; session_register("myvar");?> second_page.php3 <? session_start(); echo $myvar; ?> I've launched first_page.php3, then I've launched second_page.php3: the browser doesn't display anything (it should display the world "test").
View Replies !
PHP4 Sessions And Arrays
I'm currently working on a PHP4/MySQL generic shopping cart project, but I am having problems with the cart section. At present, my 'add one item to cart' function works using sessions and arrays, something like: PHP Code:
View Replies !
Php4+apache1.3+xp With Sessions Not Working...
I seem to have a major problem with sessions on my setup. No simple example seems to work. Example below: page1.php: <?php // page1.php session_start(); echo 'Welcome to page #1' $_SESSION['favcolor'] = 'green' $_SESSION['animal'] = 'cat' $_SESSION['time'] = time(); // Works if session cookie was accepted echo '<br /><a href="page2.php">page 2</a>' // Or maybe pass along the session id, if needed echo '<br /><a href="page2.php?' . SID . '">page 2</a>' ?> Page2.php: <?php // page2.php session_start(); echo 'Welcome to page #2<br />' echo $_SESSION['favcolor']; // green echo $_SESSION['animal']; // cat echo date('Y m d H:i:s', $_SESSION['time']); // You may want to use SID here, like we did in page1.php echo '<br /><a href="page1.php">page 1</a>' ?> Output after pressing page2 link: Welcome to page #2 1970 01 01 00:00:00 page 1
View Replies !
Possible For Sessions To Work Under PHP5 And Not Under PHP4.
I'm writing an web application with PHP/MySQL. I used PHP5 but believed to use code that would work also under PHP4. However when I tried my application under PHP4 I got the warning that the headers are already sent and my session did not work. I do understand that I have to send the headers before anything else. But does anyone know what kind of difference between PHP4 and PHP5 makes it possible for sessions to work under PHP5 and not under PHP4.
View Replies !
Returning NULL Vs. Returning FALSE
It seems to be a generally adopted convention to have a function return FALSE in case of an error. But if a function is supposed to return a boolean anyway, one cannot distinguish anymore between the "normal" FALSE and the "error" FALSE. So why not using NULL instead to indicate an error? Are there drawbacks I am not aware of?
View Replies !
Creating User Sessions W/out Using Sessions
I'm working on a user management system where I can use the benefits of PHP sessions w/out messing with them. Basically, my idea is to have an entry created into a "sessions table" when the user logs in. The table contains such info as the user's id number and the date/time they logged in. When the user logs out, the entry is deleted. In each page/script, it checks to see if the user is logged in by checking the sessions table for an entry w/their IP address and the date, to make sure it is fairly current (unless anyone can think of a better way to check). Now my delema....obviously, I don't want people that don't properly log out to have a session that could last weeks (depending on when they visit again). I am thinking a script that cleans up entries that are old would do the trick, but obviously I want this script to run say, at least once an hour. Obviously, I am not going to be able to sit at my computer and run this script every hour of every day. I was thinking of using the script and doing a cron job, but I think my host only allows one cron job per day...and only at night. Any thoughts??
View Replies !
How Do Different Sessions Work? Multiple Sessions
I use a messageboard which uses sessions. I have a login script which uses sessions. I have a charting app which uses sessions. How does PHP handle this? Does it create three different sessions or is everything handled by the one session file? In other words, is it working like magic and I don't need to worry about it. What I'm confused with is that at the start of the login script there is a start_session() and other session related stuff. On logout, the session is destroyed. Now does this affect the start_session() of the other scripts?
View Replies !
SQL Not Returning Value Even Though It's There...
I have been having fits with a simple PHP script and I'm hoping it's something that someone here can help me with. Basically, when I execute the SQL statement directly on the MySQL CLI, it returns. But when I run the same statement through the following PHP script, I *think* it returns an empty set. I say I think because the if(mysql_num_rows($recset) > 0){} block is executed. But when I try to retreive values stored in my array, === SCRIPT === <?php include("db.php"); $incoming_user = stripslashes($_POST['username']); $sql = "SELECT * FROM tblSisters WHERE username != '$incoming_user' AND isTaken != 'yes' ORDER BY RAND() LIMIT 1"; $recset = mysql_query($sql, $conn); if(mysql_num_rows($recset) > 0){ $row = mysql_fetch_row($recset); echo "<table border="1" align="center" cellspacing="7"> "; echo "<tr> "; echo "<th>USERNAME</th> "; echo "<th>WANTS MAIL</th> "; echo "</tr> "; echo "<tr> "; echo "<td>$row[username]</td><td>$row[wsm]</td> "; echo "</tr> "; echo "</table> "; // Update the database to reflect the new selection $sql2 = "UPDATE tblSisters SET isTaken='yes', takeBy='$incoming_user' WHERE username='row[username]'"; mysql_query($sql2, $conn); } else{ echo "<h2><u><b>RECORD RETREIVAL FAILURE</b></u></h2><br> "; echo "The secret sister database could not be queried. Please try again "; echo "later or contact the system administrator. "; } ?> === END SCRIPT ===
View Replies !
Not Returning First Row
I have the following code, and it's connecting and pulling the information, however, when only one line is returned, it's not displaying it. Though if I have 2 rows, it will display the 2nd row but not the first. Code:
View Replies !
SMS Returning...
In the client side i have a popup menu, if this menu pops up and in that time refresh comes this menu drops down in the default state. Is there any decision how to fix this situation? I see in some sites <iframe> which reloads a php every ... seconds, may be i can use it to popup sms? or have any other decisions?
View Replies !
Returning The Whole URL
im trying to retrieve the entire URL using php and so far not had much luck, i have tried using <?php echo $_SERVER['REQUEST_URI'];?> which will return everything after http://localhost:6789. here is the entire URL... http://localhost:6789/p03272434/emudom/register.php?UName=seen using <?php echo $_SERVER['REQUEST_URI'];?> returns..... p03272434/emudom/register.php?UName=seen can anyone help ?
View Replies !
SELF Not Returning URL
I use $_SERVER["SCRIPT_NAME"] in order to work out where on the server the PHP app has been installed. This is then used (amongst other things) to build absolute links in the resulting page sent to the client, of the form: <a href="<?=_INSTALLDIR?>index.php">Link</a> This works great on a couple of development servers, with a fairly standard Apache installation, but on the big ol' live server (Apache 2, PHP 5) it doesn't. This seems to be because of either virtual directories and/or URL rewriting (?!) that results in SCRIPT_NAME / PHP_SELF etc. all returning the file system path to the current file, and *NOT* the URL that appears in the address bar, which is required to build the links. Code:
View Replies !
Way Of Returning Something Differently??
I have created a table with one of the columns being a datetime column.nOnce the date and time has been collected off of the person submitting, i would like to show the date and time in the way of: Dec 22 2000 22:09:01 Is it possible to do this via PHP rather than it outputting the usual:
View Replies !
ID Of Record Not Returning ?
The following code returns the fields from the row ( $product for example is used later and displays OK ) except the 'prid' field ( only ever has zero), which is the unique ID for this table. Any thoughts appreciated - PHP Code:
View Replies !
Returning References
according to the php manual, it said: Do not use return-by-reference to increase performance, the engine is smart enough to optimize this on its own. I doubt if this only apply to the PHP5 engine, while if I am using PHP4, performance is a factor to continue to use return by refercnece?
View Replies !
Returning Results With An '
I am using this script $mresult = mysql_query("SELECT DISTINCT game FROM vids order by id desc limit 50", $link) or die ("query 1: " . mysql_error()); while ($mrow = mysql_fetch_array($mresult)) { $count = mysql_result(mysql_query("SELECT COUNT(*) FROM vids where game = '$mrow[game]'"), 0); } but for any $mrow[game] that has an ' in it a 0 is returned, how do I fix this?
View Replies !
Returning A True 404
My .htaccess file reads: ErrorDocument 400 /404.php ErrorDocument 401 /404.php ErrorDocument 403 /404.php ErrorDocument 404 /404.php This means if someone types in the wrong address (e.g. www.mysite.com/wrongpage.php ) then they are automatically redirected to 404.php Now, I would like this to continue, but also return a true 404 (as required by Google), can you tell me how to do this? Can you confirm that just placing the following at the top of my script suffices: header("HTTP/1.0 404 Not Found"); even if I use ob_start and ob_flush?
View Replies !
PHP And Returning References
I've noticed something strange with returning references, both in PHP4 and 5 - maybe it's supposed to do this, I don't know - but it seems a bit weird nonetheless. Say we have the following test code:
View Replies !
Session_id() Returning No Value
below is the code i'm using, however i've also tried logging in, and using an echo session_id(); this isn't working either, I've started the session, it shows up in my sess directory, the variables are being maintained in the session but, session_id() wont return the id.. any idea what could be causing this? This is all the relevant code in using. session_save_path("tmp/login/"); session_start(); #bunch of stuff between here :P $setkeys = mysql_query("UPDATE `users` SET `ip` = '" . getenv("REMOTE_ADDR") . "', `sessid` = '" . session_id() . "' WHERE `users`.`uid` =" . $result['0'] . " LIMIT 1 ;");
View Replies !
Returning XML Data
I have a javascript client (ajax) and the xmlhttprequest object POSTs to a file called getQuestion.php. I want to return an xml string. This is what happens. Code: $xml = simplexml_load_file('example.xml'); echo $xml->asXML(); Now, when I do a direct call to this script (not from client, but putting the url in the browser manually) I get the text from the xml file but not the xml forms. If I view the SOURCE in the browser, there's the XML. But my javascript will NOT receive it for some reason. The xmlhttprequest.responseXML is null.
View Replies !
Returning Arrays
I have this really annoying problem in a PHP script. I have a function that checks a number of HTML input fields for errors. When it finds an error, a variable called $error that is set to true. Then, at the end of the script, there is an if statement that checks to see if $error is true. If it is true, then the function returns false, as well as returning $error_msg, which is an array. The problem I have is that the function does not seem to be returning the array. It returns the false just perfectly, but it refuses to return the array.
View Replies !
Returning A Variable
I have 2 functions, the 2nd function relies on a variable from the first delcared function. although i can echo the vars in function #1, i can't in function #2 BTW: im am using classes(); class SportdStats{ var $id; var $user; var $gameresult; //#################################// function SelectCappers($id){ $query = "SELECT capper_id, upoints FROM sportd_cappers WHERE capper_id > Ƈ' "; $result = mysql_query($query); $row = mysql_fetch_array($result); $id = "$row[capper_id]"; $upoints = "$row[upoints]"; echo $id . "_$upoints<br>"; } function EchoId($id); { echo $id; }
View Replies !
Returning More Than One Values
I have a function currently that return a string to the main body: PHP Code: function example(){ // some codes here return $to_print; } i would need to return another numeric result from this function..Is there a way to return two values from a function? For example, can i: PHP Code: function example(){ // some codes here return $to_print; return $number; } If its possible, how can i get the value in the main program?
View Replies !
LIKE With OR's Returning
I have a job table that as an FK to a states table which, of coourse, holds all the states. The FK is state_id. Essentially, when somebody searches, I use LIKE to compare the term to several different fields. The problem is that the query returns a result for every state. So, if teh result should return 3 jobs, it returns 153 (50 states + DC) * 3. $q = "Select j.job_id, j.title, j.company, j.description, j.showStart_date, j.url, j.city, j.confirmCode, s.name FROM jobs j, states s WHERE j.tags LIKE '%$term%' OR j.description LIKE '%$term%' OR j.title LIKE '%$term%' AND j.state_id = s.state_id AND j.end_date > $now ORDER BY j.end_date ASC"; . If I strip out the OR statements and only go with 1 LIKE statement, it works.
View Replies !
Returning All Positons
I had the following declaration: $string = "encyclopedia"; And let's say that I wanted to return the positions of all "C" characters within the string variable. In this instance, I would want it to return 2 and 4, since those are the positions of the "C" character within the string. I saw some functions on the official PHP site, but they only seem to return the first position of a character.
View Replies !
Returning An Sql Entry
I am inputting a antryp to my database using the following code: $query1 = "insert into topic (description, forum_id, starter) values ('$topic', '$forum', '$username')"; $result1 = $handle->query($query1) i need it to return the ID field from the record just created.
View Replies !
Returning Specific
I'm new to PHP. I have a properties database (MYSQL). When I click on a specific link, the results show all the properties in the database, however what I need the results to show is not all the properties but ones that meet a certain criteria. I want it to show the ones that are listed as "Rentals" only.
View Replies !
Returning An Image
im not sure on where to start with this. i need the code to return as an image. as in, not like using html to add a link to the image like <img scr="image.jpg"> litually if on a html page i can add this html: <img scr="image.php"> and it would return an image
View Replies !
Returning To Previous URL
I have a field in my database that a script checks, for example check.php If the field in my database has a N in it the check.php file redirects me to. say nocheck.php. What I want to know is how do I get the URL I got sent from to get to nocheck.php mainly because I am going to run the script that in check.php on numerous pages and I wish to send the user back to that page after nocheck.php is complete.
View Replies !
Returning Primary Key
I have a script that is inserting data into a mysql database table. mysql_query("INSERT INTO billing SET userid='$userid', billingdate='$billingdate', invoice='$invoice'"); What I want to know is if there is a way to return the billingid value for the row that is inserted without querying the database for the record? For Example: mysql_query("INSERT INTO billing SET userid='$userid', billingdate='$billingdate', invoice='$invoice' RETURN billingid");
View Replies !
Returning DISTINCT
I have a table that has a date field in it and i want to return distinct months. I currently use "SELECT DISTINCT DateAdded FROM tblJobs"; The problem with this is it will return every day of the month. I need it to only return Jan, Feb, Mar etc.
View Replies !
Returning Rows
All users are in the users table, so every user will have a row. Not all users have images uploaded, so in the user_images table, they may not have rows. I want to select the user from the table whether or not he/she has any default images. If the user_images table has no rows for $id, then i should still get results if there is a row for $id in the users table. How do I do this? Current SQL: SELECT * FROM user_images,users WHERE user_images.ownerID = '$id' AND users.id = user_images.ownerID AND (`default` = '1' OR `default` IS NULL) LIMIT 1
View Replies !
MSSQL_QUERY Not Returning True
According to php.net, mssql_query is supposed to return true when no rows are returned. I'm actually getting an empty resource identifier instead of true. The table is empty, there are no rows in it at all, so mssql_query should always return true, but it isn't. Am I missing something? Here's my code:
View Replies !
Functions Always Returning True
Basically I have a function that authorises someone's login details. It hashes the password they've input and matches it up with the password hash stored in the database. The problem I'm getting is that the function always returns true. The function is as follows: PHP Code:
View Replies !
Returning 1 Result From MySQL
I know the usual way of receiving results from MySQL, useing a while loop e.g. $sql = "SELECT * FROM users WHERE email='joe@hotmail.com'"; $result = mysql_query($sql,$connection); while ($row = mysql_fetch_array($result)){ echo $row["firstname"]; echo $row["lastname"]; echo $row["email"];} BUT, if I know they only 1 result is going to be returned, is there a way to do this without using a while loop? So if I only wanted to get only the firstname of the person with email joe@hotmail.com. can I do this without a while loop or do I have to use one?
View Replies !
Returning Unique Records
I'm fairly new to PHP and MySQL. I have a MySQL table that contains information on members of a club. I'll oversimplify and say the fields are first name, last name, and email address. Some members may share the same email address, say a husband and wife. So I might have two records, one for the husband and one for the wife, with the same email address. I need to return records from the table that only return unique email addresses. It doesn't matter which record I return when there is a duplicate email address, but I only want one record for each unique email address. I can use "SELECT DISTINCT email FROM Members", which gets me one record for each unique email address but omits the name fields. How do I write a SELECT statement that returns the other fields while only returning one record for each unique email address?
View Replies !
Returning A Null Reference In PHP 4.4.2
Consider a class that encapsulates an associative array. It has two "setter" methods: class A { .... function setAttribute( $name, $value ) { $this->attributes[ $name ] = $value; } .... function setAttributeByRef( $name, &$value ) { $this->attributes[ $name ] =& $value; } .... The following "getter" method *used* to work just fine prior to version 4.4.2: .... function & getAttribute( $name ) { if ( isset( $this->attributes[ $name ] ) ) return $this->attributes[ $name ]; return NULL; } .... However, as of version 4.4.2, this throws a "FATAL: Only variable references should be returned by reference." error. Unfortunately, my host (and several of my client hosts) are stuck on this version. Is there an elegant way to solve this problem? I want to return a value indicating that no such attribute exists. (I've googled the problem and can't find anything useful other than a suggestion in a PHP bug report that I learn how to write "proper" code.)
View Replies !
Returning To Signup Form
i have a basic signup POST form, with php on the same page. how do i return to this page with all the entries still present, yet with a message at the top, for when the user enters one invalid entry?
View Replies !
Returning A URL From A User Search
returning page results from a form. 3 fields need to be returned: Companyname address1 webpage This is an example of what I need returned: Grey's Living Spa 9200 Anylane Rd., Columbus, OH 12345 [visit this site] The companyname and address1 are displaying, but I need the correct code to put that webpage (the mysql fieldname is 'webpage') in the correct href tag in php. Code to date: //$row = $result->fetch_assoc(); $row = mysql_fetch_assoc($result); echo '<p class="blue3"><strong>'.($i+1).' ' // display the Company echo htmlspecialchars(stripslashes($row['companyname'])); echo '</strong>' echo '<strong><br /' // dipslay the Address echo stripslashes($row['address1']); echo '<strong><br /' // display a link to the company's site echo '<br>' echo '</p>'
View Replies !
Returning A Parse Error?
why is this returning a parse error? It says the error is on the last line, I thought I was following the syntax.... <?php $link = mysql_connect("localhost"); if(! $link) die("Could not connect to MySQL"); $database = "PC_Store"; mysql_select_db($database) or die ("could not open $database: ".mysql_error() ); $Choice = $_POST['myradio']; $db = mysql_connect("localhost", "root"); mysql_select_db("PC_Store",$db); if ($Choice = 'Sales Data') { ?> <BR> Enter The Fields For Entry Into SalesData Table <form action="<?echo $PHP_SELF?>" method=POST> <input type="text" name="TransID"size=10>TransID <BR><input type="text" name="ProductID"size=10>ProductID <BR><input type="text" name="TransCode"size=10>TransCode <BR><input type="text" name="Date"size=10>Date <BR><input type="text" name="UnitsSold"size=10>UnitsSold <input type="submit" name="submit" value="Submit Data"> </form> <?php $result = mysql_query("INSERT INTO salesdata VALUES ($ProductID,$TransCode,$Date,$UnitsSold.)",$db) }
View Replies !
Query Returning Array
I'm missing something very obvious, but it is getting late and I've stared at it too long. I am writing a basic function (listed at the bottom of this post) that returns data from a query into an array. The intent is that the following code: $foo = dbSelectData("SELECT foo, bar FROM table", $link); would return an array with the keys: 'foo' and 'bar'. But what I get is instead a multidimensional array. Doing a var_dump on $foo turns out to be array(2) { ["foo"]=> string(5) "Stuff" ["bar"]=> string(10) "More Stuff" } I'm wondering where I went wrong in writing the function below. function dbSelectData($query, $connection, $rtype=MYSQL_ASSOC){ $result = mysql_query($query, $connection); if(!$result){ dbThrowError("Error in function dbSelectData. Query Was <em> $query</em>."); return FALSE; } else{ $numrows = mysql_num_rows($result); if($numrows == 0){ return FALSE; } else{ while($rows = mysql_fetch_array($result, $rtype)){ $output[] = $rows; } mysql_free_result($result); return $output; } } }
View Replies !
Returning A File Through A Script...
I'm trying to setup a script where a user would download a file from it, and the download count for that file would be incremented. I don't want to have a redirect page though, I'd like to be able to have them put myscript.php?fileid=5 into DAP for example, and the script would increment the download count and directly pass them the file. How can I do this?
View Replies !
Foreach Is Returning Value Of First Key For All Keys
I'm having trouble with the foreach function. I'm using it twice inside a user defined function with two different arrays, and in the second instance it's returning the value of the first key for all the keys. My code is shown below and the problem areas are marked with comments. In case you're wondering, this script is for generating sticky checkboxes that include an event handler. <form> <?php if (! is_array($like)) { $like = array(); } function make_checkbox_click ($name, $query, $options, $onClick) { foreach ($options as $value => $label) { printf('<label><input type="checkbox" name="%s[]" value="%s" ', $name, $value); # This is the instance of foreach that's not working correctly. # It's returning the value of the first key for all the keys. foreach ($onClick as $key => $event) { printf ('onClick="%s" ', $event); } if (in_array($value, $query)) { echo "checked "; } echo "/> $label</label><br /> "; } } # End of user defined function. $characteristics = array( 'personality' => ' I love their personalities.', 'minds' => ' I admire their minds.', ); # This is the array that foreach isn't working correctly with. $charClick = array ( 'personality' => "alert('Aren't they the greatest?');", 'minds' => "alert('They're smarter than most people their age.');", ); make_checkbox_click (posPoints, $posPoints, $characteristics, $charClick); ?> </form>
View Replies !
PHP Returning A HTTP Error
I have a application that is accessing a php script via HTTP, and I will need the script to return anything other than HTTP 200 OK, using PHP occasionally. What code can I use to make a HTTP error returned?
View Replies !
Returning Autogenerated ID On New Item
Lets say you have a form that when saved to the mysql database creates a unique incremental id. The form is just the first part of a series of things the user can do, so once the ID is created, the page would need to know immediately what this ID is. Is there a way to grab this ID instantly once it is created? Obviously if this were a sign-up for and a new user name and password are involved, you can have the user login after the initial set up and this select statement would bring back the ID. But the situation I have doesn't work like that. The way I have been dealing with this is simply to have a select statement after the initial insert that requests the record based on a couple of other fields that are likely unique. But this seems like a rather kludgy way of doing it. Is there some other solution.
View Replies !
Returning To Same Spot On Page?
I have a page that uses PHP_SELF to refresh and add more content. The problem is that the new content appears in the middle of the page, so I would want the user to return to the middle of the page and not the top after the trip to the server. Large sites like www.nytimes.com have this. When you click on a link, read the story and then use the back button to return to the main page, you return to the section of the webpage that has the link you clicked, not the top of the page. Is this created by code? Can I do it with PHP_SELF?
View Replies !
Returning A File To Browser Via Php
I need to be able to "send, or stream" a file to the client browser using PHP code. This is the scenario. The user clicks a link on a page (after logging in to the site). I need to have my PHP code return a document -a Word document file, let's say - to the browser for display. However, the document is not in the public WWW folder. For security reasons, it is on another drive on the same machine. I need to have the php code return the file to the browser so that I can wrap security code around this process.
View Replies !
Function Not Returning Expected Value
I have a php file that contains a couple of arrays used for state/country pull-down lists. I have two global arrays and an accessor method for each. I have some simple logging methods, so I know a little bit about what I'm getting back. When I try to get the arrays from another file using the accessor methods, I get no array back. Within the file that contains the arrays, I can access them by global name and also by the accessor methods. Any ideas why I cannot access the arrays from another file? Code below. <SNIP FROM CALLING METHOD> require_once BASE . '/config/formfields.inc.php' // file with needed arrays // the calling method function display_states($smarty){ logobj(function_exists(get_states)); // returning True/1 $s = get_states(); logobj($s); // no love here logobj(BASE . '/config/formfields.inc.php'); // it's the right file }
View Replies !
Returning Array Value From Function
I have a function whose purpose is to return an array of values to be used elsewhere on a page, but I can't seem to get it to ouput the array. (When I try to reference the $territory variable outside the function I get nothing.) Here's my function: Code:
View Replies !
|