473,666 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("localho st","dba","mast erkey","tms");
if(mysqli_conne ct_errno()){
echo "Connection Error";
exit;
}

$query="select username from reg_user";
$result=$conn->query($query );
$num_results=$r esult->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($r ow['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..o r 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 1335
so**********@ya hoo.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("localho st","dba","mast erkey","tms");
if(mysqli_conne ct_errno()){
echo "Connection Error";
exit;
}

$query="select username from reg_user";
$result=$conn->query($query );
$num_results=$r esult->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($r ow['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..o r 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("localho st","dba","mast erkey","tms");
is only valid if some classdefinition of mysqli exists.

And did you try to connect to the database without the abstractionlaye r?
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 abstractionlaye r.

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
3615
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 <<<<<<<<<<<<<<< Instead of saying 3.23.57, shouldn't it show 5.xx.xx? Or, did I do something wrong?
0
1283
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 record set back :-/ I hear this is a limitation on the MySQL "driiver" in PHP5. So, anyone know where I can read more? James
3
2107
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
3221
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, Andromeda Online (www.andromedaonline.net) is going into beta soon. It runs on an evaluation edition of SQL Server 2000 (our intention is, when it launches, we earn the money to buy a copy before the evaluation expires).
0
1366
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. Here is an example: function example(){ global $table, $mysqli; $min = 2; $stmt = mysqli_prepare($mysqli, "SELECT SUM(Id) FROM $table WHERE
1
2255
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. i want to learn php in and out with intrcacies tell me how to go about it
6
6795
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 running SuSE Enterprise Linux 10. The PHP version installed is v5.1.2. Product Name = "DB2 Personal Edition"
4
1459
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 php.ini However I have tried both of these and I still get the error: Fatal error: Call to undefined function mysqli_connect() I was wondering if somebody can help? It's probably something simple I've forgot to do.
1
5459
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 during socket I/O read from web-server retrieving URI . Explanation message: 'java.io.IOException: An existing connection was forcibly closed by the remote host.'." 3."Error occurred during connection to server . Explanation message: 'Connection...
0
8448
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8783
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8552
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.