473,382 Members | 1,407 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

got trouble connection to mysql5 using php5...need help

my environment:
===========================
-php ver 5.2.0
-mysql 5
-windows xp
-apache 2
-all of these are on the same machine

my code:
==========================
<html>
<body>

<?php
echo "browsing users";

$conn=new mysqli("localhost","dba","masterkey","tms");
if(mysqli_connect_errno()){
echo "Connection Error";
exit;
}

$query="select username from reg_user";
$result=$conn->query($query);
$num_results=$result->num_rows;

echo "<p>num of records found: ".$num_results."</p>";
for($i=0; $i<$num_results; $i++){
$row=$result->fetch_assoc();
echo "<br/Username: ";
echo stripslashes($row['username']);
}
$result->free();
$conn->close();
?>

</body>
</html>
problem
==========================
-if i run the code the only thing that shows is "browsing users".
-this line >echo "<p>num of records found: ".$num_results."</p>"; <<
is not also showing up
-is there something wrong with my code...logic..or syntax?
-or i wasnt able to obtain communication with mysql that's why nothing
appears. and if so, what have gone wrong why i cannot to mysql?

Jan 18 '07 #1
1 1316
so**********@yahoo.com wrote:
my environment:
===========================
-php ver 5.2.0
-mysql 5
-windows xp
-apache 2
-all of these are on the same machine

my code:
==========================
<html>
<body>

<?php
echo "browsing users";

$conn=new mysqli("localhost","dba","masterkey","tms");
if(mysqli_connect_errno()){
echo "Connection Error";
exit;
}

$query="select username from reg_user";
$result=$conn->query($query);
$num_results=$result->num_rows;

echo "<p>num of records found: ".$num_results."</p>";
for($i=0; $i<$num_results; $i++){
$row=$result->fetch_assoc();
echo "<br/Username: ";
echo stripslashes($row['username']);
}
$result->free();
$conn->close();
?>

</body>
</html>
problem
==========================
-if i run the code the only thing that shows is "browsing users".
-this line >echo "<p>num of records found: ".$num_results."</p>"; <<
is not also showing up
-is there something wrong with my code...logic..or syntax?
-or i wasnt able to obtain communication with mysql that's why nothing
appears. and if so, what have gone wrong why i cannot to mysql?
Which Database abstraction layer are you using?

$conn=new mysqli("localhost","dba","masterkey","tms");
is only valid if some classdefinition of mysqli exists.

And did you try to connect to the database without the abstractionlayer?
Also check if you updated your php.ini so it uses mysqli.dll instead of
mysql.dll.
In such cases I always check first if things connect succesfull by using php
native commands first before using the abstractionlayer.

Regards,
Erwin Moller
Jan 18 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Sarah Tanembaum | last post by:
Though I installed MySQL5 and PHP5, how come my phpinfo() shows as follow: MySQL Support enabled Active Persistent Links 0 Active Links 0 Client API version 3.23.57 <<<<<<<<<<<<<<< ...
0
by: Centurion | last post by:
Hi All, Anyone know where I can get some more detailed info about the status of MySQL5 stored procedures support in PHP5? I can run the procedures without significant drama, but I don't get a...
3
by: Klaus Hansen | last post by:
Hi all Using Windows XP, PHP4.3.11 and Mysql 4.1. Im a newbie to PHP and Mysql. Im trying to connect to the database with this script: <?php //list_db.php
14
by: BlackHawke | last post by:
My Name is Nick Soutter, I am the owner of a small game company, Aepox Games (We're in the middle of a name change from "Lamar Games"), www.lamargames.net. Our first commercial game,...
0
by: ojorus | last post by:
Hi; I am using the mysqli-extension on all my database queries. Everything worked just fine when I used MySQL 4, but when the database was upgraded to MySQL 5 (5.0.22), I got a strange error....
1
by: arunsuriindia | last post by:
i have installed php5 manually and mysql5 automatically i want to have connectivity between the two. i am newnie i broke my head fro 3 days and no relief. tell me step by step what to do. ...
6
by: michael.schmitz | last post by:
Hello, my tiny PHP5 test application cannot establish a connection to a database while I am able to connect to the same database using the DB2 command line tool. Our server is 64 bit system...
4
by: opswordfish | last post by:
Hi I've visited a lot of forums regarding getting MySQL5 working with PHP5 in IIS and it seems that with MYSQL5 you need to use mysqli in PHP and that you need to uncomment the extension in...
1
by: sahillihas8487 | last post by:
1.Unable to successfully establish a connection to web-server retrieving URI . "Web-server closing the connection after connection was just established." 2."General un-handled exception occurred...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.