Jump to content

Skorpio

Members
  • Content Count

    52
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Skorpio

  • Rank
    Regular Member
  1. I hadn't thought of any alternatives other than return and echo the function which I have now, function navmenu($db){ $data = $db->query("SELECT * FROM menu")->fetchAll(PDO::FETCH_ASSOC); foreach ($data as $row) { return "<li><a href='{$row['url']}' title='{$row['title']}'><i class='{$row['icon']}'></i> {$row['header']}</a></li>"; } } then // Navigation Menu Function echo navmenu($db);
  2. Thanks, when I put in the additional $row information I again added too many quotes. This has solved the issue which has resulted in the following code foreach ($data as $row) { echo "<li><a href='{$row['url']}' title='{$row['title']}'><i class='{$row['icon']}'></i> {$row['header']}</a></li>"; } If I use the quotes around the {$row['header']} -> '{$row['header']}' they print out on screen. Removing the 2 single quotes has solved the issue and when I view source I get the following <li><a href='?page=home' title='Home Page'><
  3. Thanks for this however as I say I want to put the whole navigation code block into a function so the closing a and li would be an issue. From trying the code I get
  4. Thanks for this. It gives me part of the solution however I get the echo and quotes printed on screen. When I look at the colour coding in brackets the closing single quote, square bracket and closing brace are highlighted in red
  5. I have a navigation list displaying which is a mix of html and php, everything is working fine however now I want to convert this block of code into a function but am having major problems with quotes. The line of code I currently have is $data = $db->query("SELECT * FROM menu")->fetchAll(PDO::FETCH_ASSOC); foreach ($data as $row) { ?> <li><a href="<?php echo $row['url']; ?>" title="<?php echo $row['title']; ?>"><?php echo $row['icon'] . ' ' . $row['header']; ?></a></li> <?php } ?> As I say everything works using the
  6. I am trying to resolve the initial problem, getting nowhere fast. so it should read $ As the variable is storing all data records? So Should read foreach ($row as $rows){ Is that what you are meaning requinix? The foreach that I am using in the 2nd example works as far as the navigation however I cannot include the content for the page within the foreach which makes the join redundant. I am unsure what the solution is to this but I feel as though I am going round in circles. The above, my first code with the foreach loop would present m
  7. Although still looking to resolve the issue with my php above I am looking at other solutions. Although the followi8ng code populates my navigation menu correctly I am unable to get the page data to sync with the appropriate navigation choice. $sql= "SELECT * FROM menu LEFT JOIN pages ON menu.id = pages.page_id"; $stmt = $db->query($sql); $row = $stmt->fetchAll(PDO::FETCH_ASSOC); // To print array out echo "<pre>"; print_r($row); echo "</pre>"; Then where the navigation is I have <?php for
  8. What is? As I say the SQL is working, it is the PHP thats the issue.
  9. In addition, the returned array when using fetch all.
  10. Hi I have a 4 button navigation, home, projects, about and contact. This is in one table, menu, this table has the relevant icon to display with the appropriate link and another field is the link itself, ?page=home. Menu is joined with the pages table using the following query SELECT * FROM menu LEFT JOIN pages ON menu.id = pages.page_id When I run this through phpmyadmin sql console everything is returned as expected, all pages match up with the navigation. When I print_r($row); all 4 fields from the nav table and all 7 fields from the pages table, totalling 11 fields, displa
  11. Regarding I can run up to version 7 on the live server through cpanel however the host only supports up to 5.4 which obviously raises issues such as not renewing with them unless they update to at least 5.5 but that's another issue. The levels for access is something I was thinking about for the future but I need to get my head around PDO and Php in general without being overly ambitious but you have given me a lot to think about. Thanks for the suggestions and the help.
  12. I think I have found the reason for the 500 error if nothing else, my host only supports up to php 5.4 so the verify and hash are not supported but that's another issue. but the above code is running but I am still testing the is_valid you suggested.
  13. These are the current checks I have, everything running on xampp but when testing on live server throws a 500 after submission, does not show errors. So I have this, if($pdo){ $stmt = $pdo->prepare("select username, password, active from users where username = :username"); $stmt->bindValue(":username", $username); $stmt->execute(); $user = $stmt->fetch(PDO::FETCH_ASSOC); if($user === false){ $msg = ''; $error .= 'Incorrect Username/Password combination'; } else { $validPassword = password_verify($unhashed, $user['password']); if($validPassword)
  14. Starting with your last point, I have removed count and am checking I was planning on the function but wanted to get the code working here first. As the prepared statement is only checking for the username it is returning true even if the password does not match. As I said in my original post I am just going round in circles. If I place the above code in a function function check_credentials ($pdo, $username, $unhashed){ $stmt = $pdo->prepare("select username, password, active from users where username = :username"); $stmt->bindValue(":username", $username); $stmt->
×
×
  • 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.