Skip to main content
Inspiring
July 31, 2010
Question

Mysqi query returns nothing

  • July 31, 2010
  • 1 reply
  • 748 views

I'm migrating from asp.net to php so I hope you'l be patient with me...

I setup an connection with dreamweaver:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_database = "localhost";
$database_database = "test";
$username_database = "root";
$password_database = "6627_ac_4033";
$database = mysql_connect($hostname_database, $username_database, $password_database) or trigger_error(mysql_error(),E_USER_ERROR);
?>

And then I try to do a query with mysqli but it returns nothing, this is my code:

<?php

     require_once ('connections/database.php');
     
     $query = "select id, name from da_groups";
     $mysqli = new mysqli();
     $mysqli->connect($hostname_database,$username_database, $password_database, $database_database);
     if ($mysqli->connect_error) die ( $mysqli->connect_error);
     $result = $mysqli->query($query,MYSQLI_STORE_RESULT);
     if ($mysqli->error) die ('Could not find groups in database');
     
     
     while ($row = $result->fetch_array('MYSQLI_ASSOC')){
          
          echo $row['id'];
          echo $row['name'];
          
          
     }
     
     $result->free();
     $mysqli->close();
     

?>

It still returns nothing even if I change the parameters in $mysqli->connect directly to the proper hostnames and password etc.

Now there's also somethin different, when I first used the connection file this returned a connection error wich I can't reproduce now.

I'm a litle stuck with this code, please help me

This topic has been closed for replies.

1 reply

Inspiring
July 31, 2010

Never mind found it, I used parenthesis where I shouldn't do....

Lawrence_Cramer
Inspiring
August 3, 2010

Nothing helps you find the answer like posting to a forum!  There must be something about typing out the question that makes the subconscious work a little harder and bingo, the answer comes as soon as you hit the send button. There must be studies on this phenomena, or their should be...

--   
Lawrence   *Adobe Community Professional*
www.Cartweaver.com
Complete Shopping   Cart Application for
Dreamweaver, available in PHP and CF

Stay updated - http://blog.cartweaver.com