Jump to content

objnoob

Members
  • Posts

    327
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by objnoob

  1. Here's the original...
  2. Yep. There's a number of issues and misunderstandings you're experiencing, so i'll end with a single suggestion... KISS
  3. Yeah, I see. He's knee deep without the basics. I'm sure it's a copy paste snippet here and snippet there collection of code statements in an attempt.
  4. The limit is here: $sql = "SELECT * FROM $this->tablename WHERE `staff_id`='".clean_db($id)."' LIMIT 1"; This means sql::sql_result would be no more than 1 row ALWAYS! So, checking the number of rows is moot. Fetch once.... if the fetch is false on the first fetch, you've got 0 rows, otherwise 1. Second fetch is not necessary, but may require a free result or close cursor to free up the database's result buffer.
  5. Yes, it would be wise. However, you are storing the result in $this->sql_result. So, you COULD just $data = $db->sql_result->fetch_array(); I don't recommend this because it limits you to 1 sql_result, and you will not be able to use sql::query() again while relying on sql::sql_result.
  6. No need, since the query has a LIMIT clause.
  7. You're looping through each item in the $data array. The number of items in the $data array depends on the fetch mode you're using. Since you're not explicitly specifying a fetch mode (fetch num, fetch both, fetch assoc, etc) you will have to assume the default fetch mode is being used. The default fetch mode, assuming you're using fetch_array() method of a mysqli_result object, is both. This will represent each column of a mysqli_result row twice; once by column index and once by column name. Since each column is represented twice, any and all row arrays (fetch_array) fetched will have an even number of items. x columns multiplied by 2 representations will always total an even number of representations (2, 4, 6, . So, expecting 3 is just not possible. Now that we've covered your fetch both mode paradox, there are other inhibitions that I spot in your code. Caliing $db->query($sql); should, if it doesn't, result with a return value that is not being stored. You should design the query() method of your sql class to return a value that represents the query's result! $the_returned_result = $db->query($sql); // query the database and set the variable $the_returned_result to the returned value of sql::query() $data = $the_returned_result->fetch_array(); // fetch from the returned value
  8. Yes, but your checklogin.php is incomplete and doesn't really do anything. login_success.php is lacking too. Here's some tutorials to get you on the right track. http://www.webhostingjams.com/web-development-top-5-php-and-mysql-login-scripttutorials/
×
×
  • 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.