| | |
php require problem
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 496
Reputation:
Solved Threads: 0
Hi,
I create dbf.php file to connect database and require dbf.php in main.php but, doesn't work.
Thanks
dbf.php
main.php
I create dbf.php file to connect database and require dbf.php in main.php but, doesn't work.
Thanks
dbf.php
PHP Syntax (Toggle Plain Text)
<?php $conn = mysql_connect('localhost', 'root', ''); if (!$conn) { die('Could not connect: ' . mysql_error()); } else { mysql_select_db('dbf', $conn) or die('Could not select database.'); } ?>
main.php
PHP Syntax (Toggle Plain Text)
<?php require '../dbf.php';?>
i think you didnt provide password on line:
or simply use this code below:
PHP Syntax (Toggle Plain Text)
$conn = mysql_connect('localhost', 'root', '');
PHP Syntax (Toggle Plain Text)
<?php mysql_connect('localhost', 'username', 'password') ; mysql_select_db('dbname'); ?>
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
•
•
Join Date: Jul 2008
Posts: 41
Reputation:
Solved Threads: 7
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'dbpassword';
$dbname = 'databasename';
$errorMessage = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname);
$sql = " QUERY ";
$result = mysql_query($sql)
or die('Query failed. ' . mysql_error());
?>Hi..
once try to do this.....may be it will help u..
With Regards,
Kishore
Kishore
you shoud seek out a tutorial on writting PHP classes. this will help you a lot in the future. it's good practice in my opinion to write it once and reuse it forever. building up a library of classes will help you not having to waste time rewriting or copy/pasting/modifiy'n
look around the web for a good PHP or PHP/MySQL cookbook, they are good sources for learning quickly and correctly.
hope this helps!
look around the web for a good PHP or PHP/MySQL cookbook, they are good sources for learning quickly and correctly.
hope this helps!
![]() |
Similar Threads
- URL Rewrite in PHP (PHP)
- php/mysql dynamic multi-level menu problem (MySQL)
- Stuck inserting php page "include" (PHP)
- Drag and Drop - scrollable lists problem (JavaScript / DHTML / AJAX)
- Paging Problem (PHP)
- WHERE statement problem. (PHP)
- IE problem with "about:blank" & "search for..." (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: forget password
- Next Thread: Downloaded file show 0byte
| Thread Tools | Search this Thread |
ajax apache api array basics beginner binary bounce broken cakephp checkbox class cms code codingproblem combobox cron curl database date display dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration interactive ip java javascript joomla js limit link login mail menu mlm mobile multiple mysql nodes oop outofmemmory paging parse paypal pdf php problem procedure query radio ram random recursion regex remote return script search server sessions smash sms soap source space sql syntax system table tutorial up-to-date update upload url validation validator variable video web webapplications websitecontactform xml youtube






