472,373 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Unable to connect to mysql database

cyberking
Hi.
I have just started learning PHP along with MySQL.

I am trying to connect to the MySQL DB server but unable to. I have been tryin. Please help. Its urgent cos I shall soon have to work on PHP .

My testing program is as follows :

Expand|Select|Wrap|Line Numbers
  1.  <?php 
  2.  
  3. $si = function_exists('mysqli_connect');
  4. if($si == 1)
  5. {
  6. echo 'MySQL is installed <br />';
  7. }
  8. else
  9. {
  10. echo 'Not able to connect';
  11. }
  12. ?>
  13.  
Please help. I am unable to connect to the MySQL server
Mar 29 '07 #1
23 4113
ak1dnar
1,584 Expert 1GB
[PHP]function_exists('mysqli_connect');
[/PHP]
mysqli_connect is not the correct function
mysql_connect is the function

remove "i" from the function name
Mar 29 '07 #2
ak1dnar
1,584 Expert 1GB
When you post next time please read the posting guidelines.
Please give a proper title to your thread and wrap the coding using tags. because then from this page itself we can read the codings without going for a IDE.
Mar 29 '07 #3
Yes. Ok I ll Follow the rules from the next time.

But For now, I still am not able to connect. Please see the following statement.

$dbcnx = mysql_connect("localhost","root","my_pass");

This is in the browser gives me a Fatal Error.

Wats the prob. Please help.
Mar 29 '07 #4
ak1dnar
1,584 Expert 1GB
Yes. Ok I ll Follow the rules from the next time.

But For now, I still am not able to connect. Please see the following statement.

$dbcnx = mysql_connect("localhost","root","my_pass");

This is in the browser gives me a Fatal Error.

Wats the prob. Please help.
[PHP]$dbcnx = mysql_connect("localhost","root","my_pass");[/PHP]
this line is not in your original post.
I just made the correction of your script.here its checking weather [PHP]mysql_connect[/PHP] is defined or not.

what do you really wanted. post the complete script here.
Mar 29 '07 #5
[PHP]$dbcnx = mysql_connect("localhost","root","my_pass");[/PHP]
this line is not in your original post.
I just made the correction of your script.here its checking weather [PHP]mysql_connect[/PHP] is defined or not.

what do you really wanted. post the complete script here.
Hi.
Thanks for takin time to help me.

This is my first program where I am tryin to connect to MySQL server. The complete code is as follows:


<?php

$dbcnx = mysql_connect("localhost","root","my_pass");
if ($dbcnx)
{
echo 'Success';
}
else
{
echo ' Unable' ;
}
But I still get the same error.
Fatal Error: Call to undefined function mysql_connect

Thanks in advance
Mar 29 '07 #6
ak1dnar
1,584 Expert 1GB
Did you install mysql in your machine. this script is working fine with correct username and password to mysql server witch runs in the same machine.

[PHP]<?php
$dbcnx = mysql_connect("localhost","root","dba");
if ($dbcnx)
{
echo 'Success';
}
else
{
echo ' Unable' ;
}
?>[/PHP]

use [PHP] tags arround your php lines ;)
Mar 29 '07 #7
Is that So??

Yes I have MySQL, Apache and PHP all installed on my system. But then, why is it not working for me?

Thanks again for tryin to help me
Mar 29 '07 #8
ak1dnar
1,584 Expert 1GB
Is that So??

Yes I have MySQL, Apache and PHP all installed on my system. But then, why is it not working for me?

Thanks again for tryin to help me
Do you have phpMyAdmin installed in your system. and what is the O/S.
Mar 29 '07 #9
I have XP and I don have PhpMyadmin.
Mar 29 '07 #10
ak1dnar
1,584 Expert 1GB
I have XP and I don have PhpMyadmin.
download appserv and install it.
remove all your PHP,MySQL,Apache from the system.

give a fresh copy. Appserv is consist of PHP,APACHE,MySQL,phpMyAdmin in a single pack.

once you done try the coding again.
Mar 29 '07 #11
But do i need phpmyadmin? Is it not possible without it?

Sorry. but the reason why I am asking is because I just installed all the three, mysql, PHP5 and apache. Is there anything that I have to do in the php.ini file. i even added the php_mysql.dll extension in the php.ini
Mar 29 '07 #12
ak1dnar
1,584 Expert 1GB
But do i need phpmyadmin? Is it not possible without it?

Sorry. but the reason why I am asking is because I just installed all the three, mysql, PHP5 and apache. Is there anything that I have to do in the php.ini file. i even added the php_mysql.dll extension in the php.ini
You have to put libmysql.dll to Windows dir.
Mar 29 '07 #13
You have to put libmysql.dll to Windows dir.
I tried doin it. But still without any results, I still get the same error.. please help.
Mar 30 '07 #14
ak1dnar
1,584 Expert 1GB
Problem is with your system not in the coding. so it is up to you. here we can help if there is a error in the coding. again we can give the suggestions for up your system.thats it.
Mar 30 '07 #15
Thanks again for replyin.

Well let me tell you everythin. I have altered my php.ini file.

Uncommented the extension=php_mysql.dll statement
I have the dll files in the system32 directory.
Php works with apache.
The phpinfo() function shows me all the configuration of php.
I am even able to create tables in MySQL, but the prob is when I try to connect to MySQL thru PHP. I have been tryin for nearl 24 hrs now and no success. Thanks for helpin me all the while. Can you suggest somethin..
Mar 30 '07 #16
ak1dnar
1,584 Expert 1GB
what are the dlls are available under system32.
Mar 30 '07 #17
what are the dlls are available under system32.
php_mysql.dll
php_mysqli.dll
libmysql.dll
Mar 30 '07 #18
ak1dnar
1,584 Expert 1GB
under Apache httpd file try to find out this line.

LoadModule php5_module D:/AppServ/php5/php5apache2_2.dll


here in my machine php5 and apache2.2 so in your one version number might be changed.

if it not available add it.first do a search in your php directory.

*php*apache*.dll

if it available check the loadmodule line in httpd.
Mar 30 '07 #19
Thanks again.

But then, as I said I have no problems in viewing php files in my browser. PHP works fie with Apache. I had also modified the LoadModule statement in the httpd.conf file.
Mar 30 '07 #20
ak1dnar
1,584 Expert 1GB
Thanks again.

But then, as I said I have no problems in viewing php files in my browser. PHP works fie with Apache. I had also modified the LoadModule statement in the httpd.conf file.
oops I missed that. ok in php.ini check this line.
mysqli.default_port = 3306
Mar 30 '07 #21
Yes thats the same as what u have mentioned. its 3306. But still cant get it connected
Mar 30 '07 #22
ak1dnar
1,584 Expert 1GB
Add the extention line for msqli to ini file and always restart the node other wise changes never work.
extension=php_mysqli.dll
Mar 30 '07 #23
Yes. I ll do that. Also BTW, if I rollback to php4 will there be chances that I can get it working? Right now I am using PHP5. I have heard that there is no embedded support for MySQL in PHP5. Thanks again
Mar 30 '07 #24

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Mr Dygi | last post by:
Hi, PHP 4.3.4 installed manually from package *.zip and Apache 2. I have a problem with this simple code: <?php $link = mysql_connect("127.0.0.1","","") or die("Could not connect: " ....
12
Rahulnewdelhi
by: Rahulnewdelhi | last post by:
hello all Hello all I installed php, mysql and IIS in xp. Problem is this while i run following file PHP Code: ---------------- <?php
1
by: iceboy | last post by:
Hello to all,I have a problem to connect PHP & MySQL together. I have created a form that gets the username & password from admin and connect him to database.the part of PHP script that connect to...
1
by: ynyus75 | last post by:
Hey! I am unable to connect some of the services that I host from my laptop at home, such as SMTP and MySQL on port numbers 25 and 3306 respectively. But I am able to some services such as...
8
by: malaysiauser | last post by:
Im new user of PHP and MySQL. I tried to use a script package for my web. I'd created a database. And my connection scripts are as follow; <?php $mysql_host="localhost"; ...
1
by: Markw | last post by:
Hi folks I think I've got a variable problem but not 100% sure. Background: I took the CMS example from chapter 6 in "Build your Own Database Driven Website Using PHP&MySQL" and have attempted to...
1
by: swarajtnj | last post by:
HI Everybody, I am a newly person on MySql Database. I am using ASP.net 2.0 with Using the Database as MySql 5.0. My client server 63.247.82.34. The server previlages as create a database as 2....
5
Markus
by: Markus | last post by:
I'll leave out the annoying 'i'm a newbie' speech and get to the point: i'm a newbie at perl ;) First thing i ever wrote in perl and it doesnt work. I'm using xampp as my localhost - with perl...
10
rhitam30111985
by: rhitam30111985 | last post by:
hi all .. java/jdbc newbie here ... i cant seem to perform the most basic step for database connectivity using java . here is my code : import java.sql.*; public class connect { ...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.