Forums

PHP

This topic is locked

PHAkt problems

Posted 01 Sep 2001 09:07:18
1
has voted
01 Sep 2001 09:07:18 Robert Landrigan posted:
I'm getting the following error on any page i have a recordset connect to a MySQL db...

Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /usr/www/users/rlandrig/adodb/adodb.inc.php on line 1

This happens on page load - is there something else that i need to add to teh code beyond what PHAkt adds?

Replies

Replied 01 Sep 2001 15:50:21
01 Sep 2001 15:50:21 Tim Green replied:
No, you don't need to add anything else.

This sounds like a case of PHP not being configured correctly.

Ensure that the following line in your PHP.ini has no semi-colon in front of it :-

error_reporting = E_ALL & ~E_NOTICE

and ensure that :-

error_reporting = E_ALL & ~E_NOTICE
error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR

have semi-colons in front...

It could be a number of other things too, but unfortunately you haven't given your system/server setup info.

Please ensure that you read the FAQ before posting here, it will save everyone a lot of time. The link for the FAQ can be found in my signature.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 01 Sep 2001 19:07:58
01 Sep 2001 19:07:58 Robert Landrigan replied:
Sorry for the double post - browser crashed in middle of submit, and I didn't teh first one show up.

I'm using a pair.com account, running PHP 4.03pl1 on freeBSD. The DB in question is MySql. It sounds like my challenege will be in finding the PHP.ini file, now - I'm not sure if i have access to it. Thanks for the help

Robert Landrigan
Replied 01 Sep 2001 19:41:16
01 Sep 2001 19:41:16 Bruno Mairlot replied:
This is not a configuration, but rather a p a r s e error.

(Actually, this forum has a bug, if you type p a r s e in one word, it will shows as parse)

This is actually a typical p a r s e error, and probably that with the code, we could help a lot more.

"First they laugh at you, then they fight you, then you Win..." Ghandi
Replied 01 Sep 2001 19:55:32
01 Sep 2001 19:55:32 Robert Landrigan replied:
Here's the code, as generated by UD/PHAkt

&lt;?php


// Copyright (c) Interakt Online 2001
// www.interakt.ro/

require("./adodb/adodb.inc.php";
require("./Connections/horde.php";
?&gt;
&lt;?php
// *** Edit Operations: declare Tables
$MM_editAction = $PHP_SELF;
if ($QUERY_STRING) {
$MM_editAction = $MM_editAction . "?" . $QUERY_STRING;
}

$MM_abortEdit = 0;
$MM_editQuery = "";
?&gt;
&lt;?php
// *** Insert Record: set Variables

if (isset($MM_insert)){

// $MM_editConnection = MM_horde_STRING;
$MM_editTable = "active_sessions";
$MM_editRedirectUrl = "";
$MM_fieldsStr = "textfield|value";
$MM_columnsStr = "field1|',none,''";

// create the $MM_fields and $MM_columns arrays
$MM_fields = explode("|", $MM_fieldsStr);
$MM_columns = explode("|", $MM_columnsStr);

// set the form values
for ($i=0; $i+1 &lt; sizeof($MM_fields); ($i=$i+2)) {
$MM_fields[$i+1] = $$MM_fields[$i];
}

// append the query string to the redirect URL
if ($MM_editRedirectUrl && $QUERY_STRING && (strlen($QUERY_STRING) &gt; 0)) {
$MM_editRedirectUrl .= ((strpos($MM_editRedirectUrl, '?') == false)?"?":"&" . $QUERY_STRING;
}
}
?&gt;
&lt;?php
// *** Insert Record: construct a sql insert statement and execute it
if (isset($MM_insert)) {
// create the sql insert statement
$MM_tableValues = "";
$MM_dbValues = "";
for ( $i=0; $i+1 &lt; sizeof($MM_fields); ($i=$i+2)) {
$formVal = $MM_fields[$i+1];
$MM_typesArray = explode(",", $MM_columns[$i+1]);
$delim = $MM_typesArray[0];
if($delim=="none" $delim="";
$altVal = $MM_typesArray[1];
if($altVal=="none" $altVal="";
$emptyVal = $MM_typesArray[2];
if($emptyVal=="none" $emptyVal="";
if ($formVal == "" || !isset($formVal)) {
$formVal = $emptyVal;
}
else {
if ($altVal != "" {
$formVal = $altVal;
}
else if ($delim == "'" { // escape quotes
$formVal = $delim . $formVal . $delim;
//$formVal = "'" . str_replace("'","\'",$formVal) . "'";
}
else {
$formVal = $delim . $formVal . $delim;
}
}
if ($i == 0) {
$MM_tableValues = $MM_tableValues . $MM_columns[$i];
$MM_dbValues = $MM_dbValues . $formVal;
}
else {
$MM_tableValues = $MM_tableValues . "," . $MM_columns[$i];
$MM_dbValues = $MM_dbValues . "," . $formVal;
}
}
$MM_editQuery = "insert into " . $MM_editTable . " (" . $MM_tableValues . " values (" . $MM_dbValues . "";
if ($MM_abortEdit!=1) {
// execute the insert
$queryrs = $horde-&gt;Execute($MM_editQuery) or DIE($horde-&gt;ErrorMsg());
if ($MM_editRedirectUrl) {
header ("Location: $MM_editRedirectUrl";
}
}
}
?&gt;
&lt;?php
$Recordset1=$horde-&gt;Execute("SELECT * FROM active_sessions" or DIE($horde-&gt;ErrorMsg());
$Recordset1_numRows=0;
$Recordset1__totalRows=$Recordset1-&gt;RecordCount();
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;&lt;/head&gt;
&lt;body bgcolor="#FFFFFF" text="#000000"&gt;
&lt;form name="form1" method="POST" action="&lt;?php echo $MM_editAction?&gt;"&gt;
&lt;input type="text" name="textfield"&gt;
&lt;input type="submit" name="Submit" value="Submit"&gt;
&lt;input type="hidden" name="MM_insert" value="true"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;?php
$Recordset1-&gt;Close();
?&gt;
Replied 02 Sep 2001 15:10:38
02 Sep 2001 15:10:38 Tim Green replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Actually, this forum has a bug, if you type p a r s e in one word, it will shows as parse<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Actually it isn't a forum error at all, as the word a r s e is actually an English swear word, and it is therefore edited.

It is a configuration error as the problem is reported in adodb.inc.php, which is using undeclared variables, and hence the parse error.

This error occurs because the php.ini hasn't been correctly configured to allow variables to be dynamically declared, instead the PHP configuration is expecting variables to be implicitly declared, which is a behaviour governed by the PHP.ini file.

Robert, I have tested your code on my system with only the minor modification of the name of the Connection file, so that it will work on my setup, and it works with my PHP.ini set to the values I posted earlier.

I hope this solves your problem...

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 02 Sep 2001 17:43:13
02 Sep 2001 17:43:13 Tim Green replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Sorry for the double post - browser crashed in middle of submit, and I didn't teh first one show up.

I'm using a pair.com account, running PHP 4.03pl1 on freeBSD. The DB in question is MySql. It sounds like my challenege will be in finding the PHP.ini file, now - I'm not sure if i have access to it. Thanks for the help
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Apologies, I missed this post. Unfortunately it is unlikely that you are going to have access to the PHP.ini file if you are using a hosting service such as pair.com. However, you should be able to find out what settings they have used in their PHP.ini simply by emailing them to find out.

Some settings in the PHP.ini can be overridden manually via the code in your page, again though, it is dependant on whether or not they have enabled this.

It is also possible that they need to change register_globals to on.

More information can also be gleaned if you create a blank file and enter the line :-

&lt;?php phpinfo(); ?&gt;

and then upload it to your server. Though this doesn't disclose all of the information from the PHP.ini you might be able to get the settings that I have previously mentioned.

I do know that ideally PHAkT should be used with PHP v4.04 and above. v4.03 is now a relatively old version (current version is v4.06) and so it is very possible that pair.com are using a version of PHP that isn't properly supported by PHAkT.

Hopefully though, if you can find out what settings are being used we can work out some way to get you up and running.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 02 Sep 2001 18:02:32
02 Sep 2001 18:02:32 Robert Landrigan replied:
Thanks for all of the help! After a bit of fiddling, I decide remove some of the variables(the ones that were giving me grief aren't going to change, anyway), and everything's working like a charm.
Thanks yall!

Replied 03 Sep 2001 05:38:38
03 Sep 2001 05:38:38 Robert Landrigan replied:
So i lied<img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

global_vars is indeed turned off....is there any way to step around this problem?

And am i correct in thinking that this is causing problems across the board when trying to pass variables from one page to another?

Can I use $http_get_vars["variable"] instead of $variable?
Replied 04 Sep 2001 01:06:05
04 Sep 2001 01:06:05 Tim Green replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
global_vars is indeed turned off....is there any way to step around this problem?

And am i correct in thinking that this is causing problems across the board when trying to pass variables from one page to another?

Can I use $http_get_vars["variable"] instead of $variable?
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Yep, this is going to cause all kinds of problems because one of the pre-requisites for using the ADODB libraries is that global_vars is turned on.

You will be glad though, that this can be manually turned on via PHP Script.

At the very beginning of every file you will need to add the following code block :-

&lt;?php
ini_set("register_globals","1";
?&gt;

With a bit of luck this should solve that problem for you.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 04 Sep 2001 01:06:27
04 Sep 2001 01:06:27 Tim Green replied:
Yep, this is going to cause all kinds of problems because one of the pre-requisites for using the ADODB libraries is that global_vars is turned on.

You will be glad though, that this can be manually turned on via PHP Script.

At the very beginning of every file you will need to add the following code block :-

&lt;?php
ini_set("register_globals","1";
?&gt;

With a bit of luck this should solve that problem for you.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Edited by - rawveg on 09/04/2001 01:07:44

Reply to this topic