Jump to content

brokenglass

Members
  • Posts

    10
  • Joined

  • Last visited

brokenglass's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Also my actual code is: <?php $servername="127.0.0.1"; $username="root"; $password=""; $dbname="testdb"; $connection = new mysqli($servername,$username,$password,$dbname); $sql = "SELECT Wages FROM w WHERE Country=\"".$_POST["blah"]."\""; echo $sql; $r = $connection->query($sql); $result = $r->fetch_all(MYSQLI_ASSOC); echo $result; ?>
  2. Don't know how to edit OP but actual error is: Notice: Array to string conversion in C:\xampp\htdocs\test\processing.php on line 13
  3. Hi guys, Here's my code: <?php $servername="127.0.0.1"; $username="root"; $password=""; $dbname="testdb"; $connection = new mysqli($servername,$username,$password,$dbname); $sql = "SELECT Wages FROM w WHERE \"Country\"=\"".$_POST["blah"]."\""; $r = $connection->query($sql); $result = $r->fetch_all(MYSQLI_ASSOC); echo $result; ?> When I go to the page I get the following message: Notice: Undefined index: w in C:\xampp\htdocs\test\processing.php on line 13 Does anyone know what problem I'm having here? /stuck Cheers, B
  4. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''w'' at line 1
  5. That also returns an error. Here's my full code <?php $servername="127.0.0.1"; $username="root"; $password=""; $dbname="testdb"; $connection = new mysqli($servername,$username,$password,$dbname); if($connection->connect_error){ die("Connection failed " . $connection->connect_error); }else{ $sql = "SELECT 'Country' from 'w'"; $r = $connection->query($sql); $result = $r->fetch_all(MYSQLI_ASSOC); echo '<select>'; foreach($result as $res) { echo '<option value="'.$res['Country'].'">' . $res['Country'] . '</option>'; } echo '</select>'; } ?>
  6. Thanks mate, but I get this now: Fatal error: Call to a member function fetch_all() on a non-object in C:\xampp\htdocs\test\index.php on line 16
  7. Hi guys, Does anyone know why my code isn't working?: $servername="127.0.0.1"; $username="root"; $password=""; $dbname="testdb"; $connection = new mysqli($servername,$username,$password); $result = "SELECT 'Country' from 'w'"; echo '<select>'; foreach($result as $res) { echo '<option value="'.$res['Country'].'">' . $res['Country'] . '</option>'; } echo '</select>'; } There's not a credential issue, the table is called 'w' and the collumn I'm trying to get the values from is 'Country' Any help is appreciated. Cheers, Broken
×
×
  • 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.