vchris Posted August 5, 2006 Share Posted August 5, 2006 Hi all!I'm working on my new portfolio. I formatted my comp about 2 months back and reinstalled php, mysql, IIS 5.1... Everything works great. I can view php pages but I have 2 issues:1. Seems like I can't use absolute paths. Before formatting my comp I could modify the root folder in IIS to the site I was developing and absolute paths worked. Now when I do that, it only works for html/css and not for php includes. This works in html: <a href="/gallery/index.php">...</a> but this <?php include('/includes/header.php'); doesn't. File location is correct.2. I then tried to do a select from the db. I have 1 table with 1 row for now. I have a php file named mysql_connect.php which contains this code: <?php//This file contains the database access information.//This file also establishes a connection to MySQL and selects the database.//Set the database access information as constants.DEFINE ('DB_USER', 'root');DEFINE ('DB_PASSWORD', '******');DEFINE ('DB_HOST', 'localhost');DEFINE ('DB_NAME', 'dc');//Make the connection$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );//Select the database@mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() );?> This is the exact same code that I used to work before to connect to DBs so I don't understand why this wouldn't work. The output on the page simply stops right before this include as per the source code.BTW DB pass is correct.If you need more info, just ask! Link to comment Share on other sites More sharing options...
Little Goat Posted August 5, 2006 Share Posted August 5, 2006 you know, that used to happen on one of my webhosts... I don't know why. is this on your local machine? if so, try it on a remote host if you can. Link to comment Share on other sites More sharing options...
vchris Posted August 5, 2006 Author Share Posted August 5, 2006 you know, that used to happen on one of my webhosts... I don't know why. is this on your local machine? if so, try it on a remote host if you can.Yes this is on my dev server (my machine). Unfortunately I don't have access to another web server I could test this on. So no solution? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 5, 2006 Share Posted August 5, 2006 Put echo statements around to figure out where the control flow is going. It's much easier to debug a problem if you at least know where the execution path is. Try changing include to require and see if it generates an error. Link to comment Share on other sites More sharing options...
vchris Posted August 5, 2006 Author Share Posted August 5, 2006 Put echo statements around to figure out where the control flow is going. It's much easier to debug a problem if you at least know where the execution path is. Try changing include to require and see if it generates an error.I tried that. I put an echo statement right after where I included the mysql_connect.php file and nothing displayed. If I check the source code it stops right before the include. I can still include other files like header.php. I guess it has to do with the connection info but it is correct. I tested the login on another program (navicat 2004) and it connects and I can perform queries no problem.oh yeah and I always use require_once('mysql_connect.php'); for that file. Always worked. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 5, 2006 Share Posted August 5, 2006 Try using an echo statement right before the require statement, another one inside the file itself, and a third after the statement. All three of them should print. Link to comment Share on other sites More sharing options...
vchris Posted August 5, 2006 Author Share Posted August 5, 2006 Try using an echo statement right before the require statement, another one inside the file itself, and a third after the statement. All three of them should print.I just tried that and it seems like it stops echoing after this line:$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() ); But why wouldn't it give me at least an error message? Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 5, 2006 Share Posted August 5, 2006 (edited) The @ sign keeps it from showing an error This OR in between, defines an alternate if there is an error in the first method. But if the error gets ignored, the alternates get ignored too. So use either the @ sign to just ignore all errors in the method you use, or the OR with its alternates :)So here it would get: $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );or$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD); Edited August 5, 2006 by Dan The Prof Link to comment Share on other sites More sharing options...
vchris Posted August 5, 2006 Author Share Posted August 5, 2006 Fatal error: Call to undefined function mysql_connect() in C:\Inetpub\wwwroot\deepcoding\includes\mysql_connect.php on line 10Line 10: $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() ); Link to comment Share on other sites More sharing options...
Little Goat Posted August 6, 2006 Share Posted August 6, 2006 so in other words, your mysql function isn't configured in php.ini, or it's not working correctly. Link to comment Share on other sites More sharing options...
vchris Posted August 6, 2006 Author Share Posted August 6, 2006 I guess that would explain... How would I fix that? Link to comment Share on other sites More sharing options...
Little Goat Posted August 6, 2006 Share Posted August 6, 2006 in the php.ini, there will be a line like this:;extension=php_mysql.dllyou need to remove the semicolon (; ) and make sure that the file php_mysql.dll is in the php folder. the default location of the dll if it isn't in the php folder is the php/ext folder. copy it from there. of course, this is with Windows. I don't know how in linux. Link to comment Share on other sites More sharing options...
vchris Posted August 6, 2006 Author Share Posted August 6, 2006 That's great but what if I don't have the file php_mysql.dll in my PHP folder??? Would it be some similar solution to resolve my absolute path problem with php? Link to comment Share on other sites More sharing options...
Little Goat Posted August 7, 2006 Share Posted August 7, 2006 I already told you. it's in the subfolder /ext in the php directory. copy it from there. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 7, 2006 Share Posted August 7, 2006 There is a configuration setting in php.ini that specifies the extension directory, so look there and make sure that it is pointing to the correct directory in the first place. If you can't find where it is, search for php*.dll on your computer. If you don't find the mysql extension at all, you probably installed PHP5 with the Windows installer, which does not include MySQL support. You will need to use the manual installation package, which includes all of the extensions. Link to comment Share on other sites More sharing options...
vchris Posted August 8, 2006 Author Share Posted August 8, 2006 I already told you. it's in the subfolder /ext in the php directory. copy it from there.No subfolder ext in php folderThere is a configuration setting in php.ini that specifies the extension directory, so look there and make sure that it is pointing to the correct directory in the first place. If you can't find where it is, search for php*.dll on your computer. If you don't find the mysql extension at all, you probably installed PHP5 with the Windows installer, which does not include MySQL support. You will need to use the manual installation package, which includes all of the extensions.Where can I get this manual installation package? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 8, 2006 Share Posted August 8, 2006 PHP 5.1.4:http://www.php.net/get/php-5.1.4-Win32.zip/from/a/mirrorPHP 4.4.3:http://www.php.net/get/php-4.4.3-Win32.zip/from/a/mirrorAnd, the installation manual:http://www.php.net/manual/en/install.php Link to comment Share on other sites More sharing options...
vchris Posted August 8, 2006 Author Share Posted August 8, 2006 I'll try that tonight! What do I run first? PHP 5.1.4 or the manual install? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 8, 2006 Share Posted August 8, 2006 Those packages are the installation packages for PHP. You won't want to use the Windows installer, where you have a wizard that walks you through everything. Just download the zip file, extract all the files, copy them to their own folder, and go through the installation guide. It will tell you what files you need to put where, and how to hook it up with your server. Link to comment Share on other sites More sharing options...
vchris Posted August 9, 2006 Author Share Posted August 9, 2006 OK so I uninstalled my PHP version and installed the PHP 5.1.4 manually but when I view php pages I get a pop up to download the file... Link to comment Share on other sites More sharing options...
justsomeguy Posted August 10, 2006 Share Posted August 10, 2006 Then IIS is not set up to send PHP files to the PHP executable. Check in the manual on how to do that, you may have skipped a step. Link to comment Share on other sites More sharing options...
vchris Posted August 12, 2006 Author Share Posted August 12, 2006 So it is resolved!I was installing PHP 5 manually but followed all the steps and still didn't work. I installed PHP 5 with the windows installer and added the mysql extension and everything works. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now