Jump to content

Maq

Administrators
  • Posts

    9,363
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Maq

  1. Is this true for just PCRE, or all regex engines? You mean about \w? I only use PCRE, so I'm not versed in other engines.. but according to the Master Regular Expressions book: But yeah, depending on your locale, in may not be exactly [a-zA-Z0-9_]. For me, if I want that to be the case, I have to set my LC_CTYPE variable to 'C' (I just link to threads to save some retyping). But I digress... All in all your solution works, and that's the important thing! I agree, thanks for the info.
  2. The underscore is a single character wildcard. If you want it literally you must escape it. That would just be an underscore by itself. Do you mean entries with underscores anywhere in the field? In this case: '%\_%'
  3. Have you searched the forums? I've seen this type of question multiple times. You should also check in the manual, there are examples and snippets that deal with attachments - mail.
  4. isset Like I mentioned before, you can find all the function details in the manual. But yes, it returns a boolean.
  5. Haha thanks, I try. Is this true for just PCRE, or all regex engines?
  6. Please refer to the manual for what each of these functions do. The code there is equivalent to this: if(isset($_GET['subject'] && is_numeric($_GET['subject'])) { $cat = $_GET['subject']; } else { $cat = null; } if(isset($_GET['menu']) && is_numeric($_GET['menu'])) { $prod = $_GET['menu']; } else { $prod = null; } if(isset($_GET['menu_type']) && is_string($_GET['menu_type'])) { $menu_type= $_GET['menu_type']; } else { $menu_type = null; } ?> The only difference is that it's using ternary operators.
  7. Change this portion to: - Added some error checking. - Echoed out your second query. - Only assigned the session variables if the query returned > 0 rows. // Grab the user information that matches the username & encrypted password $query = "SELECT userid, username, usergroup FROM users WHERE username='$username' AND password='$encrypted_pass'"; echo "Query=> " . $query; $result = mysql_query($query) or die(mysql_error()); $user = mysql_fetch_array($result); $numrows = mysql_num_rows($result) or die(mysql_error()); if ($numrows > 0) { // Store the data in the session $_SESSION['userid'] = $user['userid']; $_SESSION['username'] = $user['username']; $_SESSION['usergroup'] = $user['usergroup']; return TRUE; } else { return FALSE; } You should also put this at the top of your script, for syntactical sake: ini_set ("display_errors", "1"); error_reporting(E_ALL);
  8. MadTechie the loading script doesn't stop at %100, lol.
  9. Yeah, that actually happens a lot in your script. You need to change the double quotes that are inside the primary string, to single quotes. Don't worry, if you have PHP variables they should still be interpolated.
  10. You're right, your have your SQL execution because you even check to see if anything has been submitted. You're also using a lot of javascript for some reason while you're still processing everything server side... Anyway, try changing this portion: $sql="INSERT INTO wings (CC1, GB1, Radar1, Runway1, Factory1, NP1, Residence1, PP1, Oil1) VALUES ($_POST[1], $_POST[2], $_POST[3], $_POST[4], $_POST[5], $_POST[6], $_POST[7], $_POST[8]);"; $result=mysql_query($sql)or die ("Error. Could not do SQL query!"); ?> </pre> <form method="post"> < to this: if(isset($_POST['cons'])) { $sql="INSERT INTO wings (CC1, GB1, Radar1, Runway1, Factory1, NP1, Residence1, PP1, Oil1) VALUES ($_POST[1], $_POST[2], $_POST[3], $_POST[4], $_POST[5], $_POST[6], $_POST[7], $_POST[8]);"; $result=mysql_query($sql)or die ("Error. Could not do SQL query! " . mysql_error()); } ?> </pre> <form method="POST" action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>"> <
  11. You don't tell your form where to submit. Another problem is that "login_form.inc.php" doesn't have access and doesn't know what "$login_error" even is. The last problem is that I don't see session_start() anywhere in your scripts. Wherever you use sessions you need this. * NOT TESTED * - Put function on the same page along with the submission. session_start(); if(isset($_POST['login'])) { // Attempt to log in with the provided username & password $result = user_login(strip_tags(htmlspecialchars(strtolower($_POST['username']))), strip_tags(htmlspecialchars(strtolower($_POST['password'])))); if($result === FALSE) { //Reshow the form with the error $login_error = 'Incorrect login information'; include 'global/inc/login_form.inc.php'; } else { $username = $_SESSION['username']; $query = "SELECT usergroup FROM users WHERE username = '$username'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($result); if ($row['usergroup'] == "1") { echo 'Login successful...'; echo ''; } else { echo 'Login successful...'; echo ''; } } if (isset($login_error)) { echo "There was an error: " . $login_error . ", please try again. "; } } ?> </pre> <form action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>" method="POST"> </form> <br><br><br>function user_login($username, $password)<br>{<br> // Grab the salt from the database using the username<br> $query = "SELECT salt FROM users WHERE username='$username' limit 1";<br> $result = mysql_query($query);<br> $user = mysql_fetch_array($result);<br><br> // Using the salt, encrypt the given password to see if it<br> // matches the one in the database<br> $encrypted_pass = md5(md5($password).$user['salt']);<br><br> // Grab the user information using the username & encrypted pass<br> $query = "SELECT userid, username, usergroup FROM users WHERE username='$username' AND password='$encrypted_pass'";<br> $result = mysql_query($query);<br> $user = mysql_fetch_array($result);<br> $numrows = mysql_num_rows($result) or die(mysql_error());<br><br> // Store the data in the session<br> $_SESSION['userid'] = $user['userid'];<br> $_SESSION['username'] = $user['username'];<br> $_SESSION['usergroup'] = $user['usergroup'];<br> <br> if ($numrows == 1)<br> {<br> return TRUE;<br> }<br> else<br> {<br> return FALSE;<br> }<br>}<br><br
  12. Use [nobbc][/nobbc] tags around the BBC you don't want parsed.
  13. I think I just went blind... Please surround your code with tags for proper formatting and syntax highlighting, you don't have to create your own EDIT: Damnit eRott, I said the same thing you did now I have to change it, hmm let's see...
  14. After receiving another message and deleting it, the top message nav still indicated that I had [1] message, when in actuality it's empty. Leave it, not that big of a deal, just thought you guys should know. I will report this on the SMF forums if you'd like.
  15. Did some minor testing, I'm not regexpert but they seem to work fine: $s = "2user_n3ame_"; if(preg_match("~^([\w\d_])+$~i", $s)) { echo "valid"; } else { echo "invalid"; } $u = "http://www.bebo.com/Profile.jsp?PreviewSkinId=4867349407"; if(preg_match("~http://www\.bebo\.com/Profile\.jsp\?previewSkinId=([\d])+$~i", $u)) { echo "\nvalid"; } else { echo "\ninvalid"; } ?>
  16. Look at ADDTIME(). This also seems like a MySQL issue, since I assume you want to UPDATE all of the records by adding 10 hours.
  17. That should work but try: $query = "SELECT DISTINCT visitor_ip FROM visitor_list WHERE visitor_day = '$today' and visitor_month = '$month'";
  18. Use: mysql_fetch_assoc NOT: mysql_fetch_array
  19. Your code looks correct, are you sure there aren't multiple IP's that match those conditions?
  20. That usually means your query is failing, but it's syntactically correct. You do have some spacing issues. Right before your '=' you have 2 spaces, should be one, but this wouldn't throw this warning. You don't get an error output for: ? $result = mysql_query($query)or die (mysql_error());
  21. Yes, that should work. You may want to put it in a string variable first then pass it to file_get_contents.
  22. You don't use a WHERE clause with INSERT... Maybe you want an UPDATE?? Now, what exactly are you trying to do?
  23. I'm glad it's ok now... Mind sharing the solution so others can refer to it?
  24. Maybe something like: $rand = rand(1,5); echo "rand = ". $rand . " "; switch ($match){ case 0: $match = "PRE"; echo $match; break; case 1: $match = "1st"; echo $match; break; case 2: $match = "2nd"; echo $match; break; case 3: $match = "3rd"; echo $match; break; case 4: $match = "4th"; echo $match; break; default : $match = "NAH!"; break; } ?>
  25. Maq

    hits meter

    Please don't double post - http://www.phpfreaks.com/forums/index.php/topic,252944.0.html
×
×
  • 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.