Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/18/2022 in all areas

  1. Perhaps echo '<pre>' . htmlentities(' <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> ..... </url> <url> ..... </url> <url> ..... </url> <url> ..... </url> </urlset> ') . '</pre>';
    1 point
  2. if you add the line of code that i gave to use exceptions for errors for the mysqli extension, you will get an sql error telling you why the query is failing, assuming that you have php's error_reporting set to E_ALL and display_errors set to ON. having error handling like this is a fundamental troubleshooting step, i.e. trying to teach you how to fish, rather than giving you a fish to eat every time you are hungry. please take the time to learn and use the fundamentals for this task.
    1 point
  3. $sql = "SELECT * FROM agencies_data WHERE agency_user =:username"; $stmt = $db->prepare($sql); // $db is the PDO Connection $stmt->execute([':username' => $_POST['user']); // I am 99 percenct certain : in :username is not needed / just for clarity. while ($row = $stmt->fetch(PDO::FETCH_ASSOC) { // Process results though I do not understand having a form inside a // form that has been submitted } I would concentrate in getting PDO working then onward to the logic of what you are trying to accomplish. I would pull the record one at a time to edit if that is what you are trying to accomplish? $sql = "SELECT * FROM agencies_data WHERE agency_user =:username"; $stmt = $db->prepare($sql); // $db is the PDO Connection $stmt->execute([':username' => $_POST['user']); // I am 99 percenct certain : in :username is not needed / just for clarity. $result = $stmt->fetch(PDO::FETCH_ASSOC) <input class="form-control" type="text" name="oid" value="<?= $result['agency_user'] ?>" > though that would mean you have to modify the code somewhere else.
    1 point
  4. But I like that the user is preparing himself to practice good querying.
    1 point
  5. value="<?php while($item = $stmt->fetch()) { echo $item['agency_user']; } ?>" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NO! NO! NO! You don't use a while loop when there is only a single row returned. The while loop fetches rows until there are none left, at which point item contains "false" (ie empty). You are using the prepared query incorrectly. The point of preparing queries is to avoid putting variables into the query. <?php if ($SERVER['REQUEST_METHOD'] == 'POST') { //database cn $db = new PDO("mysql:host=localhost;dbname=centrify","root",""); $stmt = $db->prepare("SELECT * FROM agencies_data WHERE agency_user = ? "); $stmt->execute([ $_POST['user'] ]); $item = $stmt->fetch(); if ($item) { ?> <input class="form-control" type="text" name="oid" value="<?= $item['agency_user']?>"> <php } } ?>
    1 point
This leaderboard is set to New York/GMT-05:00
×
×
  • 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.