Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. gwolgamott posted a code example above
  2. This is what the magic function __autoload is for. It will only include the necessary classes your code will require. However you can of course do this manually though. But there is no point including all classes and only using two or three at a time.
  3. What does your get_var() method return. Currently it is not returning anything and is why you're receiving the error you're getting. mysql_fetch_array is expecting a result resource from mysql_query, this result resource should be returned from your get_var() method, provided your query executed without any errors. Can you post the code to your get_var() method.
  4. I believe the following block of code is responsible for that error $sql = 'select * from `events` where `id` = \'' . mysql_real_escape_string($_POST['EventName']) . '\''; $res = mysql_query($sql); if ( mysql_num_rows($res) == 0 ) { $error['event'] = 1; } Here you're checking to see if an event with the same name already exists. The problem part is with your if statement. You're checking to see if no results have been returned and setting the error ($error['event'] = 1). Which is why you're receiving the 'Invalid Event' error. What you should be doing is checking to see 1 or more results have been returned instead. Corrected if statement if ( mysql_num_rows($res) > 0 ) { $error['event'] = 1; }
  5. Oh ok now I understand //add options to box foreach($this->options as $option) { $selected = (isset($_POST[$this->name]) && $_POST[$this->name] == $option) ? ' selected="selected"' : null) $text.="<option value='".$option."'{$selected}>".$option."</option>"; }
  6. Can you define what you mean by sticky? Maybe you should explain in full what you're trying to do.
  7. And your question/problem is?
  8. Your function is sort of similar to json_encode and json_decode. Cant see the use in your function though. Where would I use this?
  9. You mean 5.3.0 right? 3.5.0 is extremely old and is outdated and is most probably why your code is not working. If you're using php5.3.0 then you'll need to check to see if PHPBB3 is compatible with PHP5.3.0. If its not you should downgrade PHP to an earlier version. WAMP provides many addons for different PHP versions which you can easily install. Click here for WAMP Addons. Once installed make sure you choose the new version from wamps tray icon
  10. You'll place session_start() in all major pages your members will see, ignoring the files that are being included/required into your pages.
  11. The form will have to be submitted in order for PHP to check the values. However using javascript you can control what happens with the form, such as disable the submit button if the passwords do not match and/or display an error message. You'll want to look into javascript form validation. Here is a quick tutorial http://www.w3schools.com/js/js_form_validation.asp You can however use a javascript framework such as jQuery for form validation http://yensdesign.com/2009/01/how-validate-forms-both-sides-using-php-jquery/
  12. You'd use a basic if/else statement and the comparison operator if($_POST['pass1'] == $_POST['pass2'])) { // passwords match } else { // passwords do not match }
  13. Yea, I suppose. There is nothing there stopping you.
  14. A bit more information is required, such as your table structure and what is 'Thread TitleXX: New' etc. The more information your provide the better the answer you're going to get.
  15. A small change SELECT t.team_id, t.team_name, SUM(r.results) AS team_points, SUM(r.win) AS team_wins, SUM(r.loss) AS team_losses, SUM(r.draw) AS team_draws, FROM teams t LEFT JOIN results r ON t.team_id = r.team_id GROUP BY t.team_id ORDER BY team_points DESC
  16. Try function write_value_of($var,$oldval,$newval) { $contents = file_get_contents('config.php'); $regex = '~\\'.$var.'\s+=\s+\''.$oldval.'\';~is'; $contents = preg_replace($regex, "$var = '$newval';", $contents); file_put_contents('config.php', $contents); } write_value_of('$topics_per_page',"10","5"); I went with the regex approach.
  17. Woops my bad. I meant to say add the + operator after [[:digit:]], not [:digit:]. I forgot the extra []
  18. You'll want to join the two tables together using a simple MySQL Join, eg SELECT t.team_id, t.team_name, COUNT(r.results) AS team_points FROM teams t LEFT JOIN results r ON t.team_id = r.team_id GROUP BY t.team_id ORDER BY team_points DESC The above is an untested query. Give it a go and see what you get.
  19. You forgot the delimiters (they define the start/end of your regex pattern). I tend to use ~ as the delimiters. You'll want to wrap [:digit:] within square brackets too, otherwise you'll receive an error. Also another change you'll need to add is the 1 or more quantifier (+ symbol) after [:digit:] to match one or more numbers, otherwise your pattern will only match a single digit and not multiple. Fixed code $temp = preg_match_all("~\bInlinks\b \(([[:digit:]+])\)~", $url, $test);
  20. You can undo urlencode with its brother function urldecode. When you're passing the names in the url you'll use urlencode, eg $name = 'Jim Carey'; echo '<a href="name.php?name='.urlencode($name).'">Send Name</a>'; When you reftrieve the name from the url you'll use urldecode, if(isset($_GET['name'])) echo urldecode($_GET['name']);
  21. If you look in the source you'll see, you'll have two distinctive arrays, $array[0] will contain both the html and urls, eg Array ( [0] => Array ( [0] => <span class="url">http://some url here</span> .... rest of matches ) ) Where as $array[1] will just contains the urls (what you're searching for (.*)), eg Array ( [1] => Array ( [0] => http://some url here .... rest of matches ) ) Hope that helps to understand what preg_match_all is doing
  22. I'm guessing your config.php file is basically containing a bunch of variables. You could code your get_value_of function as function get_value_of($name) { include 'config.php'; if(isset(${$name})) return ${$name}; return false; } Now to get the value for $topics_per_page $topics_per_page = get_value_of('topics_per_page');
  23. Your url is incorrect. The format is filenamep.php?variable_name_here=some_value_here. You then use $_GET['variable_name_here'] to get the value from the url. So if your url is http://localhost/working/JobData2.php?a=16 Then you'll use $_GET['a'] to get the value of 16 from the url.
  24. You could use substr_count $count = substr_count($text, '\''); if($count > 1) echo "you have more than one '";
  25. in Just checked your checklogin.php file. How you are logging in users is incorrect. You shouldn't be creating new MySQL accounts for members that sign up to your site. // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; ... // Connect to server and select databse using substitution variables and user input mysql_connect("$host", "$myusername", "$mypassword")or die("cannot connect"); The username/password combination you use in mysql_connect() is the main MySQL account you use to manage your mysql database/tables etc. This is the only function for mysql_connect(). You do not use your members username/password details here. In my previous post about the use of session_register() I was referring to this in checklogin.php session_register("myusername"); session_register("mypassword"); The above should be $_SESSION['myusername'] = $myusername; $_SESSION['mypassword'] = $mypassword; Remember you are already getting the username/password from the login form on lines 12 and 13 in checklogin.php: // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; You should also place session_start() at the top of checklogin.php otherwise your session variables will not work as expected. The code I do not see in any of the four files you have provided is where you're checking to see if the user has logged in. You've only posted the code which logs the users in (checklogin.php), which sets up the myusername and mypassword session variables. These are the variables you'll want to check to see if the user is logged in or not, as these variables will only exist if the username/password entered in your login form found a match in your databases register table.
×
×
  • 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.