Newbie trying to fix error

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
agile4
New php-forum User
New php-forum User
Posts: 4
Joined: Sun Jul 16, 2017 7:23 pm

Sun Jul 16, 2017 7:37 pm

Hi folks,

I am trying to install the old phpFormGenerator app on a website and am about 99% good.
When I hit the submit button at the end of the form , it does not call the Thank You screen and does not send the results to my email.
The site I downloaded from offers no support.

The log has this line

PHP Parse error: syntax error, unexpected '==' (T_IS_EQUAL), expecting variable (T_VARIABLE) or '$' on .... line 20

Here is the area of code it points to,

<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
pt_register('POST','');
if($=="" || $=="" || $=="" || $=="" || $=="" || $=="" || $=="" || $=="" || $=="" || $=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(!preg_match("#^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$#i)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));

Can anyone figure out what is wrong?

Thanks

Tom

chorn
php-forum Active User
php-forum Active User
Posts: 349
Joined: Fri Apr 01, 2016 2:18 am

Sun Jul 16, 2017 11:51 pm

what should this be?

Code: Select all

if($=="" || $=="" || $=="" || $=="" || $=="" || $=="" || $=="" || $=="" || $=="" || $=="" ){

agile4
New php-forum User
New php-forum User
Posts: 4
Joined: Sun Jul 16, 2017 7:23 pm

Mon Jul 17, 2017 6:21 am

Not sure what it does. I THINK it's something to do with checking that the user has entered the required fields. It has 10 == steps and that is how many required fields there are (10 of 15)
Would it help to post the entire code?

User avatar
hyper
php-forum Active User
php-forum Active User
Posts: 380
Joined: Mon Feb 22, 2016 5:52 pm

Mon Jul 17, 2017 8:40 am

Would it help to post the entire code?
Chorn has highlighted the problem line identified in the error report for you.
old phpFormGenerator
old, being very much a good description.

In all honesty though, you're trying to use something that's 10 years old, translated that means it's out of date, insecure and you'll be spending more time trying to debug than you would take if you took the time to learn how to do it for yourself.

agile4
New php-forum User
New php-forum User
Posts: 4
Joined: Sun Jul 16, 2017 7:23 pm

Mon Jul 17, 2017 12:57 pm

Haha. I know you're right. With my schedule, it would take me 6moths to a year to learn enough to do it. Seriously. I work 10 to 14 hours a day as it is in my 2 businesses. This is a form for my wife's dog club website. I was using Tectite's form but I began having problems with some users not seeing the Recaptcha box at the end. No pattern to it that I can see. It doesn't matter if users are using Chrome, FF, IE, Edge or a MAC. Tectite has closed their forums.. And phpForGenerator seemed sufficient.

I saw where chon posted the line, but he asked "what is this". I see that is the line, but what is wrong with it?

This is the last problem I've encountered. Had a couple of hosting side issues that have been corrected.

Once I get past this error trapping issue, I think we'll be good to go.

I've done a bunch of reading and kind of understand what they are doing, just not what the issue is.

The form has required fields. This is somehow checking each required field for data and if empty, telling the user they have missed a field.

It's got to be something simple... Just not sure what.

Tom

User avatar
hyper
php-forum Active User
php-forum Active User
Posts: 380
Joined: Mon Feb 22, 2016 5:52 pm

Mon Jul 17, 2017 2:40 pm

Read the error (plain English):
unexpected '==' , expecting variable
In other words the parser came across '==' when it was expecting a variable:

Code: Select all

if ($=="" ........)
I suspect that you will have other problems if you fix this one, I don't think that you are anywhere near sorting it out (hope I'm wrong) and if you don't know what is going on in that piece of code - you don't stand any chance of fixing it (sorry to be harsh, just trying to be realistic).

If you don't want to learn coding (or don't have time), look to use a current modern CMS that already has what you want, I'm sure there are some that have clubs; if you go this route, make sure you spend the time looking for how recent the last update was and current support. Look in your control panel to see what CMSs are available and look at their web sites before you decide.

agile4
New php-forum User
New php-forum User
Posts: 4
Joined: Sun Jul 16, 2017 7:23 pm

Mon Jul 17, 2017 3:57 pm

Thanks. I know what it's trying to do If <variable equals nothing OR next variable equals nothing..... show errror.

But I agree. I'd love to learn PHP, just no time do do so right now. Since it was the last step, I though maybe it would be a quick fix, like the ereg to preg-match conversions I had to do.

I loaded this one off my hosts Softalicious offerrings. They do have some CMS apps. I'll go take a look.

Thanks
Tom

User avatar
hyper
php-forum Active User
php-forum Active User
Posts: 380
Joined: Mon Feb 22, 2016 5:52 pm

Tue Jul 18, 2017 11:05 am

If <variable equals nothing OR next variable equals nothing
Yes, that would be the pseudo code for it but not the cause of the error; what you have missed is that you have not given a variable to be evaluated - hence the error:
unexpected '==' (T_IS_EQUAL), expecting variable (T_VARIABLE)
If I turn the error around and ignore the PHP internal talk:
expecting variable, unexpected '==' given instead

Hirsty
New php-forum User
New php-forum User
Posts: 16
Joined: Tue Jul 18, 2017 1:28 pm

Tue Jul 18, 2017 1:34 pm

Good Evening,

Just so you know the error Chron pointed out is correct. The dollar character reperesents the start of a variable now unless you variable is called $==. i suspect this should be $variable1 == "" | $variable2 == "" | $variable3 == "" | $variable4 == ""

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests