Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. If you're getting this from SimpleXML, pretty much everything it returns is an object. Use typecasting like Abra showed.
  2. preg_replace() to sanitize, ctype_digit to validate. Side note: $phone = &$_POST['phone'];It's bad practice to change the contents of $_GET and $_POST in case some code somewhere really did want the original values.
  3. Don't. Just because a value consists of digits does not mean the value is a number. It should be a string, and preferably without formatting applied to it.
  4. You also said you wanted it in both the if and the else. if { output stuff } else { output stuff } equivalent to output if { stuff } else { stuff } if { stuff output } else { stuff output } equivalent to if { stuff } else { stuff } outputI picked one as an example.
  5. So yes, you are. <div> <?php include 'littlead.php'; ?> </div> <?php if ($username && $userid) { echo "You are already logged in as <b>$username</b>"; echo "<br/>Not " . $username . "? <a href='logout.php'>Logout</a>"; } else { $form = "<div id='forms'> <form action='login.php' method='post'> <table class='forms'> <td>Username:</td> <td><input type='text'name='user'/></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password'/></td> </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 Password?</a></td> </tr> </table> </form> </div>"; }Or if ($username && $userid) { echo "You are already logged in as <b>$username</b>"; echo "<br/>Not " . $username . "? <a href='logout.php'>Logout</a>"; } else { $form = "<div id='forms'> <form action='login.php' method='post'> <table class='forms'> <td>Username:</td> <td><input type='text'name='user'/></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password'/></td> </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 Password?</a></td> </tr> </table> </form> </div>"; } ?> <div> <?php include 'littlead.php'; ?> </div>
  6. Don't worry about that (unless you're actually using GTK). Cloning happens one way or another. You can provide __clone() to execute some code after the cloning happens. class NormalClone { } $a = new NormalClone(); print_r($a); $b = clone $a; print_r($b); class SpecialClone { public function __clone() { echo "Special clone"; } } $a = new SpecialClone(); print_r($a); $b = clone $a; print_r($b);
  7. New to PHP? <div> <?php include 'littlead.php'; ?> </div>
  8. IMO no, but you could very easily clean some of them up: if ($role != 'admin') { // Do nothing, exit exit ; } // Check if the user exist if (isset($_POST['user_email']) && !empty($_POST['user_email'])) { // Sanitize the data $user_email_data = trim(strip_tags(stripslashes($_POST['user_email']))); // Now use PHP to check for validation if (filter_var($user_email_data, FILTER_VALIDATE_EMAIL) && get_user_by('email', $user_email_data)) { // the user exists update_user_meta($userID, 'wp_user_roles', '10'); // check wp if the new value has been stored if (get_user_meta($userID, 'wp_user_roles', true) != '10') { wp_die('An error occured!'); } } }
  9. Well, basically, you set up your virtualhost to use *.example.com as the domain, then your PHP scripts can look at the HTTP_HOST (the subdomain specifically) to decide the city. Don't actually need URL rewriting for it. So what are you going to do about the 49 different Greenvilles? 29 Springfields? 18 Clevelands?
  10. What's the meaning behind the city? Is it like Craigslist where there's different content for each city?
  11. - Use a few other APIs to learn how other people do them. - Google "REST API" and read the results. - REST is purely HTTP headers, SOAP is regular HTTP with lots (lots) of XML, but sometimes it's easier to code for than REST (like in other languages besides PHP). - Showing examples of APIs is crazy. There's too much to post. Like I said: Google it. - Yes, a REST API is totally safe. I don't know why you would think it isn't.
  12. Don't use htmlspecialchars(). Or anything. Just output it directly. You have to do that because for some silly reason your data contains HTML markup.
  13. There's no sense in trying to make one query to pull from both tables at the same time if they aren't related. Use two queries.
  14. Which works great not counting the "without changing the first or last lines" condition. $a = $b; $b = $a;Statements don't execute at the same time. One is executed and then the next is executed.In the first step you lose the value of $a because you overwrite it with the value of $b. In the second step nothing really changes because $a and $b now both have the same value. So the problem is losing what $a had. Any ideas as to how you can hold onto its old value? Maybe you can put it somewhere temporarily?
  15. Not sure what the difference is between the "username of who is logged in" and the "user", but regardless: not really. You should do that manually in your SQL.
  16. How are those two tables supposed to be related? Only term in common is the "copy" thing.
  17. mb_substr can worry about the byte encoding for you. No mb_substr_replace() though. $str = mb_substr($str, 0, 2, "UTF-8") . "i" . mb_substr($str, 3, null, "UTF-8");
  18. No. All you have is the employee, date, and status. Why not a table with the employee, date, and status? Even better, why not a table that lists out all the employees, gives them some ID numbers so it's easier to refer to them in the database, and then a table with the employee ID, date, and status? employees id | employee ---+--------- 1 | Cary 2 | Stanlee meetings employee | date | status ---------+------------+------- 1 | 09/12/2013 | present 1 | 09/13/2013 | absent 1 | 09/18/2013 | absent 2 | 09/12/2013 | absent 2 | 09/14/2013 | present 2 | 09/19/2013 | present
  19. Eliminate the requirement of passing $date to get_jobs() so you'll get all jobs for all dates (or create a new function which doesn't use a date). Which is what your first bit of code is trying to do. Looks like you're grouping by a date, maybe with some kind of table or heading for each date. What is the rest of the code? It can almost certainly be modified so that it intelligently detects when the date changes between rows and can manage the tables/headings accordingly.
  20. Very likely. What's the code for get_job_dates() and get_jobs()?
  21. new $new = new queens_bus;
  22. With code. What kind of replies are you expecting? We only thing we know is that you have some sort of admin thing - that's it. No description, no explanation, no code, nothing.
  23. Your fetch_all is only returning one row. It has to return an array of all the rows.
  24. It seems like the most reliable indicator is not the creation time but the filename suffix. '/(?Pass that string to preg_match_all, sort the [0] matches in reverse order, and grab the first one.
  25. It's certainly possible but we need to know more. What kind of URLs do you want? Creating a new RewriteRule for everything is crazy (unless there's a very small number of them and they won't change) so you need something more dynamic than "a-nicer-url maps to product 36271". To do that there are two basic options: 1. The new URLs need to have the same information present in the old URLs but in a different form, like "/product/36271", with even more information than that if you want. 2. You alter the details.php to accept a different set of information that you do put in the new URL. Like if product #36271 is called "a-nicer-url" then you can do that, but you have to edit the script to know to look for the name instead of the ID. Also consider a URL that isn't at the top level of the website, like /product/36271 or /product/a-nicer-url. Cleaner that way.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.