PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 6th, 2005, 07:32 AM
MartyConlonJr MartyConlonJr is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 14 MartyConlonJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 10 m 52 sec
Reputation Power: 0
Global vars problem when switching from phpdev to PHP 4.3

Hi guys,

I don't know much about PHP or how its global vars work. I have a site I'm setting up where I have programmed a game engine in C++ that writes to MySQL , and also PHP code that works on the same information (I didn't code the PHP). The installation that I had running was PHPDEV at c:/phpdev/www as the web directory, but as the phpdev package included php and mysql, I wanted to install the latest versions seperately. I installed the PHP stuff to c:/PHP and the Web directory for the files was c:/WebDirectory. Now I'm getting error messages for the same code accessing mysql. It uses a global variables text file and I don't know if it is it causing the problem.

The errors I'm getting:
Warning: main(/includes/_global.inc): failed to open stream: No such file or directory in C:\WebDirectory\index.php on line 2

Warning: main(): Failed opening '/includes/_global.inc' for inclusion (include_path='.;c:\php4\pear') in C:\WebDirectory\index.php on line 2


Old site:
PHP Version: PHPDEV 4.30 with MySQL
PHP Web files stored in: C:\phpdev\www
MySQL at c:\phpdev\mysql

New site:
PHP Version: PHP 4.31
MySQL Version: 4.1.1
PHP Web files stored in: C:\WebDirectory
MySQL at c:\MySQL

_global.inc file
Code:
<?php
//Used to connect to the database
$db = mysql_connect("localhost", "phpaccess", "<PASSWORD OMITTED>");
mysql_select_db("gmba",$db);
//The current season
$currentSeason = 1;
//Used to parse date
function makeDate($date)
{ 
$day = substr($date, 8, 2); 
$month = substr($date, 5, 2);
$year = substr($date, 0, 4);
$date = $day."/".$month."/".$year;
return $date;
} 
?> 


index.php file
Code:

<?php
 
include("/includes/_global.inc");
 
?>
 
<HTML>
 
<HEAD>
 
<TITLE>GMBA.com</TITLE>
 
<LINK href="includes/styles.css" type="text/css" rel="stylesheet" />
 
</HEAD>
 
<SCRIPT LANGUAGE="JavaScript">
 
function openWindow()
 
{
 
window.open ('MembersArea/login.php', 'MembersArea', 'scrollbars=no,status=no,width=1000,height=768')
 
}
 
</SCRIPT> 
 
<BODY leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
 
<TABLE cellspacing="0" cellpadding="0" border="0" width="1000" align="center">
 
<TR>
 
<TD valign="center" bgcolor="#336633" height="75">&nbsp; 
 
<IMG src="images/Small_Logo.jpg" border="0" /> 
 
<IMG src="images/gmbafont.gif" border="0" />
 
</TD>
 
</TR>
 
<TR>
 
<TD class="crumbs" height="20">&nbsp; <SPAN class="pathway">Home </SPAN></TD>
 
</TR>
 
<TR>
 
<TD height="12" background="images/gray_top.gif"></td>
 
</TR> 
 
<TR>
 
<TD valign="top" align="center">
 
<TABLE cellspacing="0" cellpadding="0" width="100%" border="0">
 
<TR>
 
<TD valign="top" align="center">
 
<TABLE cellspacing="0" cellpadding="0" width="100%" border="0">
 
<TR valign="top" align="center">
 
<TD>
 
<TABLE cellspacing="4" cellpadding="0" width="100%" align="center" border="0">
 
<TR>
 
<TD align="center">
 
<TABLE cellspacing="0" cellpadding="0" width="100%" border="0">
 
<TR>
 
<TD width="11"><IMG src="images/ballongrey_01.gif" /></TD>
 
<TD background="images/ballongrey_02.gif"><IMG src="images/ballongrey_02.gif" /></TD>
 
<TD width="19"><IMG src="images/ballongrey_03.gif" /></TD>
 
</TR>
 
<TR>
 
<TD background="images/ballongrey_04.gif"><IMG src="images/ballongrey_04.gif" /></TD>
 
<TD bgcolor="#e8e8e8">
 
 
 
<!--- Left Menu --->
 
<? include("includes/_leftMenu.php") ?>
 
<!--- Left Menu --->
 
 
 
</TD>
 
<TD background="images/ballongrey_06.gif"><IMG src="images/ballongrey_06.gif" /></TD>
 
</TR>
 
<TR>
 
<TD rowspan="2"><IMG src="images/ballongrey_07.gif" /></TD>
 
<TD background="images/ballongrey_08.gif" rowspan="2"><IMG src="images/ballongrey_08.gif" /></TD>
 
<TD><IMG src="images/ballongrey_09.gif" /></TD>
 
</TR>
 
</TABLE>
 
</TD>
 
</TR>
 
</TABLE>
 
</TD>
 
<TD>
 
<TABLE cellspacing="4" cellpadding="0" width="100%" align="center" border="0">
 
<TR>
 
<TD align="center">
 
<TABLE cellspacing="0" cellpadding="0" width="100%" border="0">
 
<TR>
 
<TD width="11"><IMG src="images/maingreen_01.gif" /></TD>
 
<TD background="images/maingreen_02.gif"><IMG src="images/maingreen_02.gif" /></TD>
 
<TD width="19"><IMG src="images/maingreen_03.gif" /></TD>
 
</TR>
 
<TR>
 
<TD background="images/maingreen_04.gif"><IMG src="images/maingreen_04.gif" /></TD>
 
<TD align="center" bgcolor="#d3f5d0">
 
 
 
<!--- News Headlines --->
 
<? include("includes/_headlines.php") ?>
 
<!--- News Headlines --->
 
 
 
</TD>
 
<TD background="images/maingreen_06.gif"><IMG src="images/maingreen_06.gif" /></TD>
 
</TR>
 
<TR>
 
<TD><IMG src="images/maingreen_07.gif" /></TD>
 
<TD background="images/maingreen_08.gif"><IMG src="images/maingreen_08.gif" /></TD>
 
<TD><IMG src="images/maingreen_09.gif" /></TD>
 
</TR>
 
</TABLE>
 
</TD>
 
</TR>
 
<TR>
 
<TD align="center">
 
<TABLE cellspacing="0" cellpadding="0" width="100%" border="0">
 
<TR>
 
<TD width="11"><IMG src="images/mainwhite_01.gif" /></TD>
 
<TD background="images/mainwhite_02.gif"><IMG src="images/mainwhite_02.gif" /></TD>
 
<TD width="19"><IMG src="images/mainwhite_03.gif" /></TD>
 
</TR>
 
<TR>
 
<TD background="images/mainwhite_04.gif"><IMG src="images/mainwhite_04.gif" /></TD>
 
<TD align="center" bgcolor="#ffffff">
 
 
 
<!--- Main Content --->
 
<? include("includes/_main.php") ?>
 
<!--- Main Content --->
 
 
 
</TD>
 
<TD background="images/mainwhite_06.gif"><IMG src="images/mainwhite_06.gif" /></TD>
 
</TR>
 
<TR>
 
<TD><IMG src="images/mainwhite_07.gif" /></TD>
 
<TD background="images/mainwhite_08.gif"><IMG src="images/mainwhite_08.gif" /></TD>
 
<TD><IMG src="images/mainwhite_09.gif" /></TD>
 
</TR>
 
</TABLE>
 
</TD>
 
</TR>
 
</TABLE>
 
</TD>
 
<TD align="center" width="200">
 
<TABLE cellspacing="4" cellpadding="0" width="100%" align="center" border="0">
 
<TR>
 
<TD valign="top" align="center">
 
<TABLE cellspacing="0" cellpadding="0" width="100%" border="0">
 
<TR>
 
<TD width="11"><IMG src="images/ballongreen_01.gif" /></TD>
 
<TD background="images/ballongreen_02.gif"><IMG src="images/ballongreen_02.gif" /></TD>
 
<TD width="19"><IMG src="images/ballongreen_03.gif" /></TD>
 
</TR>
 
<TR>
 
<TD background="images/ballongreen_04.gif"><IMG src="images/ballongreen_04.gif" /></TD>
 
<TD align="center" bgcolor="#d6e5aa">
 
 
 
<!--- Boxscores --->
 
<? include("includes/_rightMenu.php") ?>
 
<!--- Boxscores --->
 
 
 
</TD>
 
<TD background="images/ballongreen_06.gif"><IMG src="images/ballongreen_06.gif" /></TD>
 
</TR>
 
<TR>
 
<TD rowspan="2"><IMG src="images/ballongreen_07.gif" /></TD>
 
<TD background="images/ballongreen_08.gif" rowspan="2"><IMG src="images/ballongreen_08.gif" /></TD>
 
<TD><IMG src="images/ballongreen_09.gif" /></TD>
 
</TR>
 
</TABLE>
 
</TD>
 
</TR>
 
</TABLE>
 
</TD>
 
</TR>
 
</TABLE>
 
</TD>
 
</TR>
 
</TABLE>
 
</TD>
 
</TR>
 
<TR>
 
<TD height="12" background="images/gray_bot.gif"></td>
 
</TR> 
 
<TR>
 
<TD align="center" bgcolor="#000000" height="20">
 
<SPAN class="pathway">
 
<a href="" style="color:white">Home</a> | <a href="javascript:openWindow()" style="color:white">Login</a>
 
</SPAN>
 
</TD>
 
</TR>
 
</TABLE>
 
</BODY>
 
</HTML>
 

Reply With Quote
  #2  
Old March 7th, 2005, 08:05 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
the problem appears to be the path.
The easiest solution would be to remove the first forward slash.

I would also advise using the extension .inc.php
Some (maybe most?) servers aren't set up to hide INC files, and will actually just display them as plain text when accessed from the web.

Reply With Quote
  #3  
Old March 8th, 2005, 01:18 AM
MartyConlonJr MartyConlonJr is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 14 MartyConlonJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 10 m 52 sec
Reputation Power: 0
Well, turns out this new MySQL connection isn't happening at all to PHP. I don't know much about how to install it. I used the latest installer version from php.net but haven't really set anything up, Anyone know a good site like a PHP-to-MySQL for dummies? All the php.ini stuff and anything else i have to set?

MySQL is running ok - I used SQLYog to view the contents and it showed the tables ok, so what's wrong is in the set up from PHP to MySQL. I used www.dslwebserver.com's tutorials to set up php, but the version in the tutorial is older than mine. And other tutorials have said to use the zip file for php rather than the installer but I didn't really understand why.

I used this example from another site
Code:
<?php
  // Connecting, selecting database
  $link = mysql_connect('localhost', 'root', '<PASSWORD OMITTED>')
     or die('Could not connect: ' . mysql_error());
  echo 'Connected successfully';
  mysql_select_db('gmba') or die('Could not select database');
  
  // Performing SQL query
  $query = 'SELECT * FROM coach';
  $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  
  // Printing results in HTML
  echo "<table>\n";
  while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
     echo "\t<tr>\n";
     foreach ($line as $col_value) {
  	   echo "\t\t<td>$col_value</td>\n";
     }
     echo "\t</tr>\n";
  }
  echo "</table>\n";
  
  // Free resultset
  mysql_free_result($result);
  
  // Closing connection
  mysql_close($link);
  ?> 


to test that the DB access isn't there at all. The error I got:


Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in C:\WebDirectory\index.php on line 3
Could not connect: Client does not support authentication protocol requested by server; consider upgrading MySQL client

Reply With Quote
  #4  
Old March 8th, 2005, 02:31 AM
MartyConlonJr MartyConlonJr is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 14 MartyConlonJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 10 m 52 sec
Reputation Power: 0
Well, I'm slowly but surely getting there. At least if I write these notes I guess the next person will know what to do.

For the error message at the bottom of the last post:

1. Go to cmd prompt.
2. Get to c:/mysql directory (Or wherever the heck it is)
3. Logon as root (mysql -u root -p <YOUR PASSWORD>
4. SET PASSWORD FOR root@localhost = OLD_PASSWORD('<PASSWORD>');
5. Typing the above it will prompt you for the new password (make it the same as it was, unless you actually intend to change it) I don't really know what the heck this does, but after I did it I could access the databases and I didn't change any scripts or anything else.

Also the _global.inc file I was using which contained the MySQL DB connect statement included in all my pages, I instead copied the segment of code into each file that was using the global.inc file. The pages now get the information from MySQL.

This means I think I can isolate the problem to being with main() which was calling the includes variable file as I also notice that the strtotime() function is failing. Perhaps there are functions that were installed with phpdev that aren't with php 4.3.1 which have been causing my problems. Sheesh....

Reply With Quote
  #5  
Old March 8th, 2005, 07:49 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
strange solution to MySQL problem... it all works fine now?

your include problem was the path... chances are had you used ./include/_file.inc it would have worked [notice the dot in the beginning]

Nonetheless, does everything work as intended now?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Global vars problem when switching from phpdev to PHP 4.3


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT