Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,182,735 members, 7,918,257 topics. Date: Monday, 12 August 2024 at 07:08 AM

Php - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Php (1957 Views)

(2) (3) (4)

(1) (Reply) (Go Down)

Php by marvzkiddx(m): 10:14am On Jun 05, 2016
<?php
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', '');
define('DB_NAME', 'db');

$connection = mysql_connect(DB_HOST,DB_USER,DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());

?>
<?php
$con = mysql_connect("localhost","root",""wink;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

?>



plsss av been tryin to connect to my database,but i cnt..dahz d code..Plss help..
and what is d 'root' and 'localhost'..I mean this>>> mysql_connect("localhost","root",""wink;
..What does d 'root' mean..Thank u.love u all

1 Like 1 Share

Re: Php by hollyfat(m): 10:40am On Jun 05, 2016
Screenshot or post the error code
Re: Php by Nobody: 10:41am On Jun 05, 2016
Your database server must have have a username and password. The default username is usually "root" while the password could be empty or any other default such as "password".

Are you running a local server such as xampp or wamp?
Re: Php by itznur(m): 10:55am On Jun 05, 2016
drop screenshot errors
Re: Php by marvzkiddx(m): 11:05am On Jun 05, 2016
owk......i will do do dat now....its on 000webhost
Re: Php by marvzkiddx(m): 11:47am On Jun 05, 2016
this is wah i wrote in connect.php



<?php
define('DB_HOST', 'mysql13.000webhost.com');
define('DB_USER', 'a5672605_4581');
define('DB_PASS', '********');
define('DB_NAME', 'a5672605_4580');

$connection=
mysql_connect(DB_HOST,DB_USER,DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());

?>
<?php
$con = mysql_connect("localhost","root",""wink;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

?>

and this is what i see When i access d website

warning:mysql_connect()[function.mysql_connect]:access denied for user 'root'@'localhost'(using password:NO)in/home/a5672605/public_html/connect.php on line 13

could not connect


plsss help me out...am new in this.please
Re: Php by Nobody: 12:36pm On Jun 05, 2016
<?php
define('DB_HOST', 'mysql13.000webhost.com');
define('DB_USER', 'a5672605_4581');
define('DB_PASS', '********');
define('DB_NAME', 'a5672605_4580');

$connection=
mysql_connect(DB_HOST,DB_USER,DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());

?>


That alone should do. Discard the second section.
Re: Php by marvzkiddx(m): 1:03pm On Jun 05, 2016
bro,pls can u email me ur.Details @ exclusivemarv@gmail.com . . . its workin well,buh wen i try signin up on it..it says smefin else...
u cn try it..www.marvzkiddz.netai.net
jus testin it tho..movin it to anoda host soon.
Re: Php by Nobody: 1:40pm On Jun 05, 2016
marvzkiddx:
bro,pls can u email me ur.Details @ exclusivemarv@gmail.com
.
.
.
its workin well,buh wen i try signin up on it..it says smefin else...

u cn try it..www.marvzkiddz.netai.net

jus testin it tho..movin it to anoda host soon.


Done!
Re: Php by marvzkiddx(m): 1:54pm On Jun 05, 2016
kk.. av u checkd d site,so u wld undastand well
Re: Php by talk2hb1(m): 10:59am On Jun 06, 2016
Are you sure MySql is not down?
Re: Php by Laolballs: 11:28am On Jun 06, 2016
marvzkiddx:
<?php
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', '');
define('DB_NAME', 'db');

$connection = mysql_connect(DB_HOST,DB_USER,DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());

?>
<?php
$con = mysql_connect("localhost","root",""wink;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

?>



plsss av been tryin to connect to my database,but i cnt..dahz d code..Plss help..
and what is d 'root' and 'localhost'..I mean this>>> mysql_connect("localhost","root",""wink;
..What does d 'root' mean..Thank u.love u all

Well these are deprecated functions, go and learn pdo .. Google search for pdo crash course.pdf. this methods is old and creepy and not secure
Re: Php by marvzkiddx(m): 10:48pm On Jun 06, 2016
ao wld i knw if its down.....And aqain cn i create database in anoda host while d domain is on anoda host..
Re: Php by Laolballs: 7:09am On Jun 07, 2016
marvzkiddx:
ao wld i knw if its down.....And aqain cn i create database in anoda host while d domain is on anoda host..

Yes its possible, it all about changing you database connection
Re: Php by Nobody: 10:28am On Jun 07, 2016
Root is the default MySql user, root doesn't require password by default in most cases. If you are not on localhost (offline server) then there's a great possibility that root has been allocated a password by your web-host.

What I normally do is to create a new MySql user and assign the user to a particular database, helps with security and is a good practice.

Creating a MySql user depends on your web-host but the steps are almost the same.
For godaddy: https://uk.godaddy.com/help/create-mysql-or-ms-sql-databases-36

For whogohost: https://www.whogohost.com/host/knowledgebase/111/How-do-I-create-a-MySQL-database.html

After creating a MySql user, in connect.php replace root with the User you created (Username) and the next quotes will contain the password you assigned.

$con = mysql_connect("servername","user","password" ;
if (!$con)
{
die('Could not connect: ' . mysql_error());
} I suggest using mysql_error() only on a development server not a production server. In production you should always try to avoid giving users too much information about errors.
Something like this is better:
die('Could not establish a connection to the database, try again');
Re: Php by Nobody: 3:40pm On Jun 07, 2016
Laolballs:


Well these are deprecated functions, go and learn pdo .. Google search for pdo crash course.pdf. this methods is old and creepy and not secure

I agree with you. But it's no obvious that the OP is very new at this. Jumping straight into PDO could get him lost on the instant. With time, I'm sure he would.
Re: Php by marvzkiddx(m): 1:10pm On Jun 08, 2016
tnnks guyz..Buh plss visit dis site marvzkiddz.netai.net den try to reqister....after registration,it brings an error code...please help me..thanks.
Re: Php by Nobody: 10:49am On Jun 09, 2016
marvzkiddx:
tnnks guyz..Buh plss visit dis site marvzkiddz.netai.net den try to reqister....after registration,it brings an error code...please help me..thanks.

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/a5672605/public_html/index.php on line 138

That's the error displayed, i guess.

Go the the specified file, 'index.php' then to line 138 of your code. Once there, replace the 'root' with DB_USER. That should work fine.

If it doesn't, we might need to see the full code written in that index.php file.
Re: Php by marvzkiddx(m): 11:41am On Jun 09, 2016
aiit bro........This is d index file tho...U cn help me check n modify.Pls

1 Share

Re: Php by FagsamPHP(m): 11:03am On Jun 10, 2016
so people still use Mysql? Shiii is deprecated

1 Like

Re: Php by Nobody: 12:52pm On Jun 10, 2016
FagsamPHP:
so people still use Mysql? Shiii is deprecated
I tire o, @op, please use my wrapper - https://www.nairaland.com/2870586/dhtmlsql-very-advanced-wrapper-mysql
Re: Php by wisemania(m): 11:00pm On Jun 12, 2016
Use mysqli Instead....or pdo
Re: Php by romme2u: 4:02am On Jun 13, 2016
dhtml18:

I tire o, @op, please use my wrapper - https://www.nairaland.com/2870586/dhtmlsql-very-advanced-wrapper-mysql

were you the one that wrote drupal module for voguepay payment platform?

i am trying to integrate voguepay into a site i am currently building with drupal 7 but discovered that the module available on their site is for drupal 6.

i would love to port the module to drupal 7 and possibly drupal 8 later as i don't want to go the manual integration route. this will make the module to be available for easy integration to me and others in future projects that need to use voguepay payment gateway.

are you still in charge of developing the module or do i need to contact voguepay for approval?
Re: Php by Nobody: 4:11am On Jun 13, 2016
^^^You know I am the one, and you are still asking. . . . .lol
Err, I dont have a standing agreement with voguepay, so i believe that you should talk to them.
And I also remember developing a drupal 7 plugin for them at that time - not sure of why they failed to publish it. But no, since they paid me for it, I cannot just release the source code to you directly since that will be a breach of contract.
Re: Php by romme2u: 5:54am On Jun 13, 2016
dhtml18:
^^^You know I am the one, and you are still asking. . . . .lol
Err, I dont have a standing agreement with voguepay, so i believe that you should talk to them.
And I also remember developing a drupal 7 plugin for them at that time - not sure of why they failed to publish it. But no, since they paid me for it, I cannot just release the source code to you directly since that will be a breach of contract.

well i wasn't too sure hence the asking embarassed

thanks man, i am going to contact them for the drupal 7 version cool

no need for the source code as my implementation may be different (if there is need to build the module) wink

(1) (Reply)

Best School Management Software / An INEC Voting Console Program Written In C Language / Data Science Group In Nigeria

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 30
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.