|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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">
<IMG src="images/Small_Logo.jpg" border="0" />
<IMG src="images/gmbafont.gif" border="0" />
</TD>
</TR>
<TR>
<TD class="crumbs" height="20"> <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>
|
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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.... |
|
#5
|
||||
|
||||
|
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? |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Global vars problem when switching from phpdev to PHP 4.3 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|