-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
okay well at this point in time, my suggestion would be to talk to your host and ask them to make sure stuff is setup right on their end, like ask them to make sure their email server is setup correctly. Show them your script as a reference. I can't think of any other reason why the script would fail, unless every email address you tried to send it to just so happens to block email from your host... which I suppose is possible if they have a history of spammers sending email from them. But yeah..I think at this point in time it would be appropriate to hit your host up and ask them wtf.
-
did you try changing mail() to send headers as shown in the document link?
-
For this example/error you posted, it is a "Notice", which 99.99% of the time means that you did something in your code that isn't "right", but it doesn't really break anything. Sort of the equivalent of getting scolded for cussing. The error means that you are attempting to use (in this case, in a condition) an array element that doesn't exist. Since php evaluates that as false, it doesn't break anything, because conditions are supposed to evaluate to true or false. Defining the variable first would make this notice go away, yes. But since the specific purpose here is to do something based on whether or not it exists, if we define it, we ruin the condition. Adding @ in front of the operation will suppress errors generated. You are right, this is not good coding practice. The "best practice" way to do it would be to make use of isset(), which you said you already made use for the error_message variable, and you should also make use of it here.
-
Okay first off, the way you currently have it, it will (sub) sort by your formula, but it will not actually show your Win/Loss Percentage numbers as its own column. In order to do that, you must include it in the SELECT part of your query, as I have shown. Also, I want to make sure we are on the same page here, as far as how this query is actually sorting your data. Your query says to first list within descending order by uEXP. Then sub-sort in ascending order by uWLP (your formula). So overall, you will see the data sorted by uEXP in descending order. Then, if there is more than one row in uEXP that has the same value, it will then subsort by uWLP's values. Example: uEXP uWLP 3 1 3 2 3 3 2 1 2 2 1 1 Is this what you are expecting to happen? If not, then give example data, showing how you want it to be sorted (give example with values of how you want the sorted data set to look like)
-
well that's just the way it is with the internets. It's a stateless protocol. Sessions are needed to keep track of things. I mean there are alternatives, involving cookies and/or using temporary db tables or flatfiles and/or passing stuff in query strings, etc.. but they aren't really efficient and/or necessary. Example: you could alternatively pass the info as part of the query string of the target page in the header() call but...that's not very efficient for popping form info... anyways, what's wrong with using session variables? It's pretty easy and straight forward...quick example: form.php <?php session_start(); // goes at the top of every script that utilizes session vars, must be before any output! // echo out message if there was a problem if ($_SESSION['error_message']) echo $_SESSION['error_message'] . "<br/>"; // make default value for form element(s). Session value if exists, or blank $name = ($_SESSION['name']) ? $_SESSION['name'] : ''; ?> <form name='someForm' action='process.php' method='post'> Name: <input type='text' name='name' value='<?php echo $name; ?>' /><br/> <input type='submit' value='submit' /> </form> process.php <?php session_start(); // goes at the top of every script that utilizes session vars, must be before any output! $_SESSION = $_POST; // assign posted variables (if any) to session array if ($_POST['name']) { header('Location: complete.php'); exit(); } else { $_SESSION['error_message'] = 'please fill out the form!'; header('Location: form.php'); exit(); } complete.php <?php session_start(); $name = $_SESSION['name']; echo "hello $name"; ?>
-
As mentioned, in general you should be doing something like $thetopquery = "SELECT uID,uLogin,(uOffensiveMen+uDefensiveMen) AS uArmySize,uGold,uLevel, (uWon/(uWon+uLost)) as uWLP FROM users$whereclause ORDER BY uEXP DESC, uWLP ASC LIMIT 5"; What is $whereclause supposed to be? I mean I can infer what it is *supposed* to be based on the variable name and its position in the query string, but did you echo out $thetopquery to see if it is showing what it is supposed to be doing? And, you still haven't answered the question I've asked you multiple times: what is it (not) doing that causes you to say something is wrong? You say something is wrong but you don't explain what is wrong? Are you seeing no results? Are you seeing result but not ordered properly? WHAT? If you cannot explain WHAT is wrong - what you want vs. what it is doing, then how do you expect yourself or anyone else to be able to fix it?
-
why yes, yes it would. What you can do is a) combine the form page with the processing script, and use the posted values as default values in your form, so if the validation fails, it outputs the form with the values the user posted. b) use session variables to have the data persist from page to page, so that if the user is kicked back to form page, you can auto-pop the form values with session variables made from their posted vars
-
Well no, your script is not NOT mailing because of register globals being on (it should be off, not on). that's unrelated. I don't really see an immediate reason why it shouldn't be working. Try sending some proper email headers (see example #2 of the mail manual entry). Try sending to a couple different email addresses. Perhaps gmail doesn't like your host and is automatically filtering emails from it.
-
well as for $email not showing up, i see in your form <input type="text" name"email" size="25" /> you are missing the = for name="email" but..if you see $name just fine and then adding that = will fix seeing $email...that means that you DO have register globals turned on?? edit: holy crap, you DO have register globals turned on! (I see it in your phpinfo() you posted). IMO you should probably find a new host ASAP. A hosting company who allows this sort of thing...
-
As for not seeing posted info: unless you have register globals turned on (which you shouldn't, and isn't something on be default unless you are using an old version of php), you can access posted variables using the $_POST array. Example: $_POST['email'] As for not getting mail: First off, did you check your spam/trash/junk folder? Where are you running this script from? using the mail() requires a mail server to be setup. If you are doing t his on your own computer with something like WAMP or XAAMP then you more than likely do not have a mail server setup. Or, if you are running this off some really cheap or free hosting service, more than likely they do not allow you to use things like mail().
-
make user of the header() function. Example: process.php // code that validates etc... // if everything is shiny... if ($valid) { // redirect to results page header('Location: results.php'); exit(); // otherwise... } else { // redirect user back to form header('Location: form.php'); exit(); }
-
since you are using / as the pattern delimiter, you need to escape the / in </span> in your last array key.
-
how about you show your full query, explain what you are trying to do, and actually explain what isn't working?
-
is there any reason why you are trying to do this with a text file instead of a database?
-
well seeing as how you don't really explain what "having a lot of trouble" means, this is just a random guess...it looks like you may really want to be doing something more like this: select Level, (Won/(Won+Lost)) as p from table order by Level desc, p asc
-
depends on what the organization's bank allows. I would suggest you contact their bank. Go to their website, call them, whatever. See what they allow, what APIs they provide, etc...otherwise, you may have to do it through an established 3rd party, paypal
-
Sticky form: text area field not retaining content
.josh replied to peppericious's topic in PHP Coding Help
textarea content/value goes between the actual tag <textarea>blahblah</textarea> -
If you use session variables to keep track of users, you can check if they are logged in and what permission level they are.
-
no you should be using the relevant methods from the zend framework to parse that. http://framework.zend.com/apidoc/1.10/Zend_Oauth/Zend_Oauth_Token.html#var$_params
-
use it with basename or pathinfo
-
No not really...Lookaheads (or other methods, like preg_match_all(), etc... will simply tell you things like if there is more than one instance of * in the string. Or in your example, only match if there are no other instances of *. The point I was trying to make is that you can have two different instances of * being used in a string and there's no way to code to know which one is a username and which one is some other random use, since they are both arbitrary values. Or in your example, yes, it checks if there are no other instances of *, but there's no way to know whether or not that one instance is a username. Or what if the username is mentioned twice in the string? Or two different usernames mentioned?
-
How to import text from one page to another according to choice?
.josh replied to oli22's topic in Regex Help
If I understand your situation correctly, a javascript solution like that is not going to work. You start out on descriptions.php and click a link that takes you to play_video.php. You are either one one page or the other. Those are two separate pages that each have their own DOM. When you click the link from descriptions.php and go to play_video.php, the browser (which is where javascript is executed - that is, client-side) no longer knows anything about descriptions.php except for in more vague terms (for example, it knows that it was the previous page you were on, which is how the back button works). On play_video.php you could technically use javascript to request the contents of descriptions.php and then try to parse it from there, but it wouldn't be through the DOM, it would be with regex or if you have a framework like jquery, you could possibly retrieve it as if it were xml. But even this is still way less efficient than having your descriptions in separate files and including them all on descriptions.php and including specific one on play_video.php. Alternatively on descriptions.php you could onclick of link pass the info to play_video.php by grabbing the description with javascript and appending it to the target url, and then using javascript (or php if you do it server-side) to add it. But this is not efficient either. For one thing, you are passing a whole bunch of extra info in a request. You will have to urlencode and decode it to make sure random characters in the description don't break the url. Then you will have to add more script to validate the description because once you do something like this, this opens a door to all kinds of security concerns that you will need to address, like cross-site scripting, code injection, etc.. Well that depends on what you ultimately are doing. It seems to me that for now, you aren't going to notice a difference in speed either way. And anyways, I'm not sure why you are shying away from the notion of keeping each description in separate files (or in a database as separate entries of a table) in the first place. It will not have some huge performance decrease that you think it will. Many people misunderstand the notion of "performance increase/decrease" and consequently blow it way out of proportion. In reality, we're talking microsecond level of differences here... -
You can use a static variable. Static variables retain their values each time you call a function. It's sort of like a global variable but within the function's scope. (You can of course also just use a global variable, but this keeps it with the function scope). Normal: function blah () { $x++; echo $x; } for ($y = 0;$y<10;$y++) { blah(); } // output: 1111111111 Static function blah () { static $x; $x++; echo $x; } for ($y = 0;$y<10;$y++) { blah(); } // output: 12345678910
-
you can urlencode it but why would you want those characters to show up in your url at all?
-
$string = 'blah *user blah'; // string to look for username in preg_match('~\*([a-z0-9]+)~i',$string,$username); $username = $username[1]; Though you are going to get false results from this, depending on your string. For example: $string = "he *probably* meant to say *username was a retard"; The code will return "probably". Unfortunately, there isn't really anything you can do about something like that...