Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Use var_dump to analyse the values correctly var_dump($_SERVER['PHP_AUTH_PW']); echo '<br />'; var_dump($row["Password"]); Whats the output now for the password values?
  2. You are getting that error because your query is failing, due to an error, to see what the error is you can use erroInfo. change line 65 to 78 to be $result = $db->query($sql); // check query did not fail (returns false on error) if($result) { while ($row = $result->fetch()) { if(!empty($row["Username"]) AND !empty($row["Password"])) { $_SESSION['user'] = $row["user"]; echo "Login Succefull!"; } else { echo "You entered wrong username and/or password. Please refresh this page to retry. It may be possible that your account doesn't exist. In this case, cancel the login box and sign up."; } } } // query failed else { $error = $db->erroInfo(); trigger_error('Unable to process login query. DB Error: ' . $error[2]); }
  3. No. return will terminate the function and return the data at that point. The second return statement will never be reached. See the documentation on return here http://php.net/return Any, way you do not need the second query. You could pass the result of calling your function to count to get the total results, this is because $stmt->fetchAll() returns a multidimensional array of all the rows returned by your query. Example function yourFunction() { ... omitted code ... return $stmt->fetchAll(PDO::FETCH_ASSOC); } // when calling your function $results = yourFunction(); // pass the result of your function to count, get the number of results returned from your function $numResults = count($results); // loop though results foreach($results as $row) { // generate xml } The alternative is instead of using return $stmt->fetchAll(PDO::FETCH_ASSOC); to have it return the PDO Statement object return $stmt; then when calling your function the code will be // when calling your function $stmt = yourFunction(); // call the PDO Statement rowCount() method to get the number of results $numRows = $stmt->rowCount(); // call the PDO Statement fetchAll method to loop through the results foreach($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { // generate xml }
  4. Where are you generating the number and setting it the session and where on the next page are getting the number?
  5. Have you made sure you are calling session_start() before the use $_SESSION's
  6. If you are using simple html dom, then there is no need for the use of xpath. You use one or the other. Both return the same result, just uses different syntax for the grabbing the data you require. This xpath //div[@class=highslide-gallery] is the equivalent in simplehtmldom as div.highslide-gallery (it uses css selectors as the dom path) The reason the script maybe crashing is because it is running out of memory? You should check your servers error logs or enable errors either in the php.ini or adding the following two lines of code at the top of your script ini_set('display_errors', 1); error_reporting(E_ALL);
  7. Sounds to me you most likely need to wrap the code that generates the number in a condition, so it only generates the number when the session variable does not exist. Eg if(!isset($_SESSION['num'])) { // generate new random number } // use random number
  8. You are making no sense at all. If want use to help you fix the code we need to know what the problem is, preferably write your response in clear English sentences
  9. What error is that? Post all error message(s) in full. It would also be helpful if you could explained what it is your are tying to do and what you are expecting the code to do? Also note when posting code place wrap it within tags or click the <> icon in the editor.
  10. Ch0cu3r

    Body of page

    Your can wrap your content in a container. See example https://jsfiddle.net/arswgywm/
  11. dirname(__FILE__) will be returning the directory of the current script, for example it will return this file path C:\xampp\htdocs\food\admin\crud\customers You will have to use dirname(dirname(dirname(__FILE__))) to get back to the food directory. The better solution would be to add your admin directory to a constant, then prefix your filepaths using the ADMIN constant, example define('ADMIN', 'C:/xampp/htdocs/food/admin'); // or as // define('ADMIN', dirname(dirname(dirname(__FILE__))) // prefix filepaths with ADMIN constant include ADMIN . '/includes/admin-header.php'; include ADMIN . '/includes/admin-navbar.php'; include ADMIN . '/admin-functions.php'; include ADMIN . '/db/dbconnect.php';
  12. The best place would be php.net/mysqli. That is the documentation for mysqli. Each function has an explanation of what arguments it requires, what it does, what it returns and a code example for how it is used. From there you should be able to convert your the mysql_* functions to the mysqli_* equivalent functions. Alternatively you may find http://codular.com/php-mysqli helpful.
×
×
  • 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.