Hi, I hope you guys can help me out~~~
when I run it localhost/config.php, it cannot display any message such
as connect successfully or failed. Do u guys have any idea?
config.php
<html>
<head><title>Cr eate Database and table</title></head>
<body>
<?php
$linkID = mysql_connect(" localhost",""," ");
print ("hello"); <---can print
Hello
if($linkID != "FALSE") <--i think
fail here
{
print("The connection to the server was made successfully.)" ;
}
else
{
print("The connection to the server failed");
}
mysql_close($li nkID);
?>
</body>
</html>
am I right? do i need to put username and password in
mysql_connect(" localhost",""," ")? i dont know where i can find it, or
how can I find it in mysql. Hope you guys can help me out~~ Thanks.
Krista 2 4235
Krista,
If you're using the default installation of MySQL (i.e. you haven't run a
grant statement to create a user), then you're script should have run. You
might want to try augmenting your connection statement with an error output
such as:
$linkID = mysql_connect(" localhost",""," ") or die ('I cannot connect to the
database because: ' . mysql_error());
Tom
"Krista" <yw*****@hotmai l.com> wrote in message
news:eb******** *************** ***@posting.goo gle.com... Hi, I hope you guys can help me out~~~ when I run it localhost/config.php, it cannot display any message such as connect successfully or failed. Do u guys have any idea?
config.php <html> <head><title>Cr eate Database and table</title></head> <body>
<?php
$linkID = mysql_connect(" localhost",""," "); print ("hello"); <---can print Hello
if($linkID != "FALSE") <--i think fail here { print("The connection to the server was made successfully.)" ; } else { print("The connection to the server failed"); }
mysql_close($li nkID);
?> </body> </html>
am I right? do i need to put username and password in mysql_connect(" localhost",""," ")? i dont know where i can find it, or how can I find it in mysql. Hope you guys can help me out~~ Thanks.
Krista
Krista wrote: Hi, I hope you guys can help me out~~~ when I run it localhost/config.php, it cannot display any message such as connect successfully or failed. Do u guys have any idea?
config.php <html> <head><title>Cr eate Database and table</title></head> <body>
<?php
$linkID = mysql_connect(" localhost",""," "); print ("hello"); <---can print Hello
if($linkID != "FALSE") <--i think fail here { print("The connection to the server was made successfully.)" ; } else { print("The connection to the server failed"); }
mysql_close($li nkID);
?> </body> </html>
am I right? do i need to put username and password in mysql_connect(" localhost",""," ")? i dont know where i can find it, or how can I find it in mysql. Hope you guys can help me out~~ Thanks.
Yes, you need to put in a username and password, which you should get from your
host. Also, you might want to use the "or die" syntax Tom suggested.
if($linkID != "FALSE")
^^^^^^^^^^ This can be better written as if (!$linkID)
or you could combine your IF and mysql_connect() statements:
if (!mysql_connect ("localhost","u sername","pw")) echo "Did not connect to DB";
And this line will produce an error if the connection didn't open correctly: mysql_close($li nkID);
You can get around that by using the mysql_connect() or die syntax or by
executing the mysql_close only if $linkID is valid. Or, if you're lazy, you
could just code it as @mysql_close($l inkID). The "@" keeps any errors from
being written.
Regards,
Shawn
--
Shawn Wilson sh***@glassgian t.com http://www.glassgiant.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bettina |
last post by:
Hello,
My domain: www.coaster.ch
My database: coasters
User: bettina
In the programm I wrote:
<?php
$db_server = "www.coaster.ch";
|
by: Kyle Goetz |
last post by:
hey, i'm new to mySQL...this meaning that i have tried ~10000 times to
install it and get it working over the past few weeks...and it always gives
me the same error (scroll further down to see it) despite following the
manual's windows installation exactly
i have version 4.0.13 for windows and i used the installer
once i was done, i followed the instructions in the manual exactly
i have no firewall running
|
by: JW |
last post by:
Hi all,
I was fine running mysql, and for some reason, after the most recent
reboot of my machine, I get the following error and I try the following
subsequent commands to try to figure things out:
# mysql
ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
# mysqld_safe
|
by: ikrabbe |
last post by:
Hi,
I want to set up a mysql server in an embedded process. I managed to start
the server in my program as described through
mysql_server_init()
Now I need a client connection to this server.
mysql_real_connect
|
by: MLH |
last post by:
I'm supposed to set a password for the MySQL root user. The output of
mysql_install_db instructed me to run the following commands...
/usr/bin/mysqladmin -u root -h appserver password mynwewpasswd
I did. It did not work. Here's the error:
/usr/bin/mysqladmin: connect to server at 'appserver' failed
error: 'Host 'appserver.crci.com' is not allowed to connect to this
MySQL server'
Another command I'm supposed to run also resulted in an...
| |
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
Hello,
I have a very simple problem but cannot seem to figure it out. I have a
very simple php script that sends a test email to myself. When I debug
it in PHP designer, it works with no problems, I get the test email. If
|
by: smatta |
last post by:
I have just installed MySql version 5.0-18 on Red Hat Fedora Core 4. It
is running but I cant connect to it using MySql Query Browser running
on my pc.
>From my pc, I can telnet to the sql server / port. I get back a garbled
message:
5.0.18-standard§}WxyuadT,☻V6F?J5i1YMT=
Should this be garbled ? or is there a problem ?
|
by: zMisc |
last post by:
I am using VB.NET 1.1 and cannot connect to a MySQL (v5) database.
I've done the following:
1) Create a DSN for MyODBC.
2) Connect using: Driver=MySQL ODBC 3.51 Driver; Server=localhost; Data
Source=test; UID=test; PWD=pwd; OPTION=3
When I run my app, I get this error: An OLE DB Provider was not specified in
|
by: Ike |
last post by:
Through Java, I am attempting to connect to a MySQL 4.12 server on a remote
computer. I can connect fine via php. I cann connect fine via Java, through
a servlet, when the servlet is on the same machine (localhost) as the MySQL
DB.
However, when they are on different machines with different IPs, calling
across the Internet (and there are no firewall issues -- I can connect fine
to the remote MySQL DB via php from the same machine, not...
|
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...
|
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,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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,...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |