| | |
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 beginner binary broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date display dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include incode insert integration ip java javascript joomla limit link login mail match menu method mlm mod_rewrite multiple mysql oop pageing pagerank paypal pdf php problem query radio random recursion recursiveloop regex remote script search server sessions sms soap source space sql strip_tags subversion support! syntax system table template tutorial undefined update upload url validator variable video virus web window.onbeforeunload=closeme; xml youtube






