Hi,
I am writing a login page but the php code to authenticate user is not working.
My login web page calls 'action="xLoginCheck.php"'. Below is the php code. I am writing to a log file to trace program flow.
I know it is ok up to the "hoho" bit. This code(version1) works. -
<?php
-
$host="localhost"; // Host name
-
$username="****"; // Mysql username
-
$password="****"; // Mysql password
-
$db_name="accounts"; // Database name
-
$tbl_name="userstbl"; // Table name
-
-
$FileName = "log.txt";
-
$FileHandle = fopen($FileName,'w') or die("can't open file");
-
fwrite($FileHandle, "hoho\n");
-
fclose($FileHandle);
-
?>
-
This code(version2) doesn't work, ie when I add the mysql_connect bit. Nothing inside the mysql_connect {} appear on the screen or the log file. I just get error page that says "website cannot display page" -
<?php
-
$host="localhost"; // Host name
-
$username="****"; // Mysql username
-
$password="****"; // Mysql password
-
$db_name="accounts"; // Database name
-
$tbl_name="userstbl"; // Table name
-
-
$FileName = "log.txt";
-
$FileHandle = fopen($FileName,'w') or die("can't open file");
-
fwrite($FileHandle, "hoho\n");
-
-
if (!$connection = mysql_connect($host, $username, $password))
-
{
-
$message = mysql_error();
-
fwrite($FileHandle, $message);
-
fclose($FileHandle);
-
die();
-
}
-
-
?>
-
Can anyone see where the problem is?? What is the best way to trace php code???
thanks
7 1922
Firstly, you should probably **** out your password as good practice for public forums.
It might be legal, but your if condition on line 12 looks a bit sus. Humour me and try: - $connection = mysql_connect($host, $username, $password);
-
if (! $connection) {
-
$message = mysql_error();
-
fwrite($FileHandle, $message);
-
}
-
fclose($FileHandle);
Also, you were only closing the file if it failed to connect.
thanks for your reply !!
I will replace user. Tried your suggestion but all I get in the log is "hoho 22". I have added an else line.
I am sure mysql server is working because I can login using the administrator tool.
I have just installed Apache, MySQL and PHP. Could it be it can't find the mysql db?? Where do i check?? -
<?php
-
$host="localhost"; // Host name
-
$username="****"; // Mysql username
-
$password="****"; // Mysql password
-
$db_name="accounts"; // Database name
-
$tbl_name="userstbl"; // Table name
-
-
$FileName = "log.txt";
-
$FileHandle = fopen($FileName,'w') or die("can't open file");
-
fwrite($FileHandle, "hoho 22\n");
-
-
$connection = mysql_connect($host, $username, $password);
-
if (!$connection)
-
{
-
$message = mysql_error();
-
fwrite($FileHandle, $message);
-
}
-
else
-
{
-
fwrite($FileHandle, "ok");
-
}
-
-
fclose($FileHandle);
-
?>
-
Try run a script like this: - <?php
-
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
-
if (!$link) {
-
die('Could not connect: ' . mysql_error());
-
}
-
echo 'Connected successfully';
-
mysql_close($link);
-
?>
What (if any) output do you get?
Tried your suggestion and I am getting Server Error. See attached.
Which server is in error??
The Apache server? When I "http://localhost/index.php" I get the right stuff on the screen.
The MySQL server? I can login using the mysql administrator tool.
Is there another server I don't know about?
thanks
does the same happen in Firefox, Safari, Chrome or Opera?
I have installed Apache, MySQL and PHP on my own PC a few days ago. I have done this so I can learn PHP and web development. This is the first time I am accessing MySQL using PHP since the install. Everything happens on my PC only. I use Internet Explorer (Windows 7) and I don't use these other web browsers.
I have been surfing for an answer and several people suggest, in php.ini, uncommenting
;extension=php_mysql.dll
but my php.ini file only has
;extension=msql.dll
Is this a problem? If I go ahead and uncomment this line it is worse.
I cannot find 'php_mysql.ddl' or 'msql.dll' on my computer. But then I am new to Windows 7 and I am not sure how to search for a file properly
I have a feeling PHP doesn't know where to find MySQL. What to do???
your server giving 500 error. Its server internal error. make sure your server is working properly
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bill Hernandez |
last post by:
Hi,
I've been writing software on the mac since 1987, but am brand new at
unix/php/mysql, and that's where I'm headed so I'm reading everything I can
get my hands on, but like anything else...
|
by: Ryan Stewart |
last post by:
I'm running MySQL server on a WinXP box at home. I have a cable
modem/router. I've set up port forwarding on port 3306 to the machine
running MySQL. I can connect locally just fine, but when I try...
|
by: Pugi! |
last post by:
On a freshly installed Fedora C3 (incl. webserver apache php mysql) i get
the following problem when connecting to mysql through a browser
(phpMyAdmin):
:
#2002 Can't connect to local MySQL...
|
by: jiing |
last post by:
Now let me describe what I have done and my purpose:
Originally, I want to user ports to install phpBB
But I found that phpBB doesn't support mysql 5.x (but the ports
installed mySQL 5.0.0...
|
by: ryanmhuc |
last post by:
I have root access to this server which has been preconfigured. I can
connect using the mysql command tool. But I cannot connect using any
mysql GUI software (I am currently tunneling the 3306 port...
|
by: xiuchuanli |
last post by:
I install Fedora 4 with web server, after that I installed mysql
5.0.15. Now I can connect to mysql from command line and
mysql-administrator and mysql-query-browser. But when I try to test to...
|
by: xiuchuanli |
last post by:
I install Fedora 4 with web server, after that I installed mysql
5.0.15. Now I can connect to mysql from command line and
mysql-administrator and mysql-query-browser. But when I try to test to...
|
by: linux |
last post by:
Sorry if this is a really dumb question. I am trying to connect to our
remote MySQL server (which is running just fine). I have a perl script
which
worked just fine on my other Fedora 4 box (all...
|
by: likigoldenstar |
last post by:
Hi,
I have some problem in developing program using PHP.
I 'll explain my platforms:
I use appserv-win32-2.5.9 as a app server.
In the server, mysql client version is 5.0.37
Problems:
|
by: scorpionbilli |
last post by:
Hi,
The local mysql server is running on my Macbook. I can access it
through the console client:
$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |