Jimmy Wu wrote:
> I have php 5.2 installed on a Windows XP Pro, along with Apache 2.2 and
> MySQL 5.0
> The server (host) I'm using is localhost, and my php scripts run
> except when trying to connect to MySQL
> I have the following php script
> echo "begin"."<BR/>";
> $con = mysqli_connect("localhost", "root", "***********");
> echo "hi <BR/>";
> if (!$con)
> echo "die";
> die('Could not connect: ' . mysql_error());
> echo "hi2";
> mysql_select_db("cake", $con);
> echo "hi3";
> $result = mysql_query("SELECT * FROM users;");
> while($row = mysql_fetch_array($result))
> echo $row['id'] . ": " . $row['username'];
> echo "<br />";
> echo "hi4";
> echo "done";
> I have set up the MySQL database called cake, along with the table called
> users, with one entry in it.
> However, the script inexplicably stops after echoing hi2.
> That means it must be connecting to the mysql server alright, and it
> must be
> stopping at the mysql_select_db, since it never gets to hi3.
> I can't figure out what's wrong, and I would appreciate any
You are using mysql_* functions with a mysqli object. You need to use
the mysqli_* functions (http://www.php.net/mysqli).