Jump to content

Wolphie

Members
  • Posts

    682
  • Joined

  • Last visited

    Never

Everything posted by Wolphie

  1. Ah, I've just realised. You've done the includes the wrong way around. Change DbConnector.php to [code=php:0] <?php class Dbvars { var $settings; function getSettings() { // Database variables $settings['dbhost'] = 'localhost'; $settings['dbusername'] = '****'; $settings['dbpassword'] = '****'; $settings['dbname'] = '****'; return $settings; } } class DbConnector extends Dbvars { var $theQuery; var $link; var $dbname; var $host; var $user; var $pass; //*** Function: DbConnector, Purpose: Connect to the database *** function DbConnector(){ // Load settings from parent class $settings = Dbvars::getSettings(); // Get the main settings from the array we just loaded $this->host = $settings['dbhost']; $this->dbname = $settings['dbname']; $this->user = $settings['dbusername']; $this->pass = $settings['dbpassword']; } function setDatabase($ndbname) { $this->dbname = $ndbname; } function connect() { // Connect to the database $this->link = mysql_connect($this->host, $this->user, $this->pass)or die(mysql_error()); mysql_select_db($this->dbname); //register_shutdown_function(array(&$this, 'close')); } //*** Function: query, Purpose: Execute a database query *** function query($query) { $this->theQuery = $query; $res = mysql_query($query, $this->link)or die(mysql_error()); return $res; } //*** Function: fetchArray, Purpose: Get array of query results *** function fetchArray($result) { return mysql_fetch_array($result); } } ?> Then as you would normally: <?php require_once("DbConnector.php"); // Include the database class $db = new DbConnector(); // Create an instance of the database class $db->connect(); // Connect to the database $query = "SELECT * FROM table; // Perform a query to the database $result = $db->query($query); $rows = $db->fetchArray($result); // Get an array with the results echo $rows["data"]; ?>
  2. Why is require_once 'DbVars.php'; placed outside of the <?php ?> tags?
  3. Generators aren't always reliable. If I were you, I'd start where thorpe suggested, reading the free PHP book on hudzilla. You don't need a book for reference when you already have awesome PHP documentation at www.php.net
  4. Post the code for DbConnector.php, it appears that the DbConnector class isn't defined.
  5. Yes, you will. As I mentioned before, this really isn't a sufficient method to use for a scale of 200 files give or take. Hence why you should use Clean URLs (mod_rewrite) when starting an application, that way you can put contingency and fail safes in place. For a pre-built website with 200 files or more and hundreds if not thousands of redirects and anchor links, I'd for sure advise against this. On the other hand, if you were just starting this application. I'd support you all the way and advise you to use Clean URLs provided you have fail safes and contingency in place. For a dynamic URL you would use something like.. http://domain.com/val1/val2/ http://domain.com/index.php?var1=val1&var2=var2
  6. Please do clarify how exactly I'm mistaken? If that is the case, it's due to your poor explanations and descriptions. If you're asking for help on something specific, state it as clearly as you can, with a description on what you want and what you're trying to achieve. Thank you. As a matter of elaboration, they're both "select" box elements. A "jump" box as you so describe is just a select box with some JavaScript implemented into it. Now please, explain as best you can what you want, and what you're trying to achieve.
  7. This is what I use: RewriteEngine on RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$ RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L] RewriteRule ^([^/\.]+)/?$ /index.php?q=$1 [L] RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?view=$1&id=$2 [L] # RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?section=$1&subsection=$2&page=$3 [L] # These rewrite rules can be used over and over for different master pages. # For example, see below. # RewriteRule ^([^/\.]+)/?$ /profile.php?user_id=$1 [L] # RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /profile.php?category=$1&page=$2 [L] # RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /profile.php?category=$1&subcategory=$2&page=$3 [L] However I doubt that would be sufficient enough for over 200 different filenames. However, it should help you out a bit. Hopefully.
  8. It's <select multiple></select> Example: <select multiple size="4"> <option>Option 1</option> <option>Option 2</option> <option>Option 3</option> <option>Option 4</option> </select>
  9. Then why even show .xxx at all? Why not just use Clean URLs? That way nobody can see any filetype/extension except for images etc...
  10. OK, now "None" is being set. However, it doesn't seem to get past if($completed != 0) { ... } So no values are being pushed into the array.
  11. Yes it should, thanks for pointing that out for me. Although doing that, I now have another problem. How will I be able to determine whether I should use "None" or not? Since $completed will always return TRUE to being an array.
  12. Ok so, If have a group of checkboxes, and I know how to get the values from each of them in an array. However, I can't seem to find a solution to only return a default value if "none" of the checkboxes are checked, and only return the values that are checked. I've tried: foreach($form_values['completed'] as $complete) { if($complete != 0) { $completed = array(); $completed = array_push($completed, $complete); } } if (is_array($completed)) { $completed = implode(', ', $completed); } else { $completed = 'None'; }
  13. http://irjaws.com/zymn/uploads//phpinfo.php Lol, I'd seriously advise against allowing .php file extensions.
  14. Could you please paste the code relevant to that error. I.e. lines 1430 - 1440 and 1060 - 1070
  15. It'd be useful if you provided some code.
  16. This is called pagination. There is a tutorial for it on the main PHP Freaks website. Here http://www.phpfreaks.com/tutorial/basic-pagination
  17. Try this: $query = sprintf("SELECT * FROM `table` WHERE `City`, `State`, `ZipCode` LIKE '%s' AND `%s` = '1'", mysql_real_escape_string('%'. $_POST['mainSearch'] .'%'), mysql_real_escape_string($_POST['Type']) ); $result = mysql_query($query) or trigger_error(mysql_error()); That's how I'd do it any way, assuming the value of $_POST['Type'] will be equal to the name of a field.
  18. Welcome to PHP Freaks, I'm sure you'll find what you're looking for.
  19. If it was me I'd look into using sockets, however you could just use file_get_contents(). PHP Reference: http://uk.php.net/manual/en/function.file-get-contents.php
  20. This is how I would do it: $query = "UPDATE `jtablegrid` SET $tmp_name = '$username' WHERE `game_no` = '$game_no_tempo'"; Just out of curiosity, what is $tmp_name? Is it just a variable storing a field name?
  21. ohhh smart I prefer to use implode(', ', $_POST['check'])); which will turn the array into a string, with the values being separated by comma's. Or you could loop through them using a foreach loop, if you want to automate things a bit.
  22. I've never had any problem writing and retreiving data from the database in any character case. Have you tried just writing a value to the database using different cases throughout and then tried validating it using lower case / upper case? A back tick is just another form of a quote, it doesn't matter what you surround them in, it's strictly for clarity and easy reading.
  23. How exactly are you going to store user information? Sessions and cookies only last so long.
  24. Do you mean you want it to go the other way around? I.e. Use Clean URLs? By the way, how is this relevant to the PHP forum?
×
×
  • 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.