GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech New php error message and I'm not sure what to fix (https://gfy.com/showthread.php?t=1355809)

Publisher Bucks 06-25-2022 09:24 PM

New php error message and I'm not sure what to fix
 
I'm getting the following error message on a basic newsletter program im putting together, I'm assuming that it may have something to do with additional white/ blank spaces in the code but, I cant find any in the code.

Quote:

PHP Parse error: syntax error, unexpected '<<' (T_SL) in /blah/blah/domain.com/news/admin/index.php on line 11
This is the index.php file code:

Quote:

<?php
require_once 'config.php';
login_required();
$users = count_query("SELECT COUNT(*) AS num FROM users");
$emails = count_query("SELECT COUNT(*) AS num FROM subscribers");
$subs = count_query("SELECT COUNT(*) AS num FROM subscriptions");
$nls = count_query("SELECT COUNT(*) AS num FROM newsletters");
$mess = count_query("SELECT COUNT(*) AS num FROM messages");
$temps = count_query("SELECT COUNT(*) AS num FROM templates");
$title = "Home!";
$content = <<<EOF
<h3>current stats</h3>
<p>$users user registered</p>
<p>$emails subscribers</p>
<p>$subs newsletter subscriptions</p>
<p>$nls newsletters</p>
<p>$mess messages</p>
<p>$temps templates</p>
EOF;
include 'layout.php'; ?>
Any help would be greatly appreciated, I've been fucking with this line 11 issue for the last 30 minutes with no resolve :/

machinegunkelly 06-25-2022 09:30 PM

https://stackoverflow.com/questions/...ide-eof-string

LaSexorcisto 06-25-2022 09:56 PM

The error was because you used '<<' instead of '<<<'. You must've edited your question to fix the code to include 3 '<'. So now your question doesn't make sense.

Publisher Bucks 06-25-2022 10:30 PM

Quote:

Originally Posted by LaSexorcisto (Post 23015392)
The error was because you used '<<' instead of '<<<'. You must've edited your question to fix the code to include 3 '<'. So now your question doesn't make sense.

Its always had three <<< in the code, thats what I don't understand, it should be working fine.

If i change that to 2 or 1 < I get a different error:

Quote:

PHP Parse error: syntax error, unexpected '<>' (T_IS_NOT_EQUAL) in /blah/blah/domain.com/news/admin/index.php on line 11
.

Publisher Bucks 06-25-2022 10:31 PM

Quote:

Originally Posted by machinegunkelly (Post 23015381)

Thanks will check it out now :)

machinegunkelly 06-25-2022 10:39 PM

Quote:

Originally Posted by Publisher Bucks (Post 23015401)
Thanks will check it out now :)

I asked last time and Konrad brought up a valid point.

But are you looking to be a hirable PHP dev? if not... look into frameworks man, you're struggling for nothing.

If you desire a job as a PHP dev, ignore me, but if not .. use a framework and skip this bullshit you're suffering through.

LaSexorcisto 06-25-2022 10:46 PM

I'm not sure why, but you are 100% bullshitting us with your "issue". The 1st error ONLY happens in you use '<<EOF'. The second error happened because you changed it to '<>EOF'. I'm not sure who you're trying to BS, but you can run the code yourself

https : // onlinephp.io/c/aacd1

machinegunkelly 06-25-2022 10:59 PM

Quote:

Originally Posted by LaSexorcisto (Post 23015406)
I'm not sure why, but you are 100% bullshitting us with your "issue". The 1st error ONLY happens in you use '<<EOF'. The second error happened because you changed it to '<>EOF'. I'm not sure who you're trying to BS, but you can run the code yourself

https : // onlinephp.io/c/aacd1

If he's workin' localhost all bets are off.. Weird shit happens in a pseudo linux environment.

I dont see any benefit in making up bugs.

k0nr4d 06-26-2022 12:03 AM

Jesus, just use quotes like a normal human being instead of this << heresy.

Publisher Bucks 06-26-2022 12:10 AM

Quote:

Originally Posted by k0nr4d (Post 23015416)
Jesus, just use quotes like a normal human being instead of this << heresy.

I was under the impression that using <<<EOF was good to use when you have multiple fields to display as far as not having to escape multiple quotes in the code?

This code will actually have several more fields on the page once’s I’ve gotten it to a somewhat ‘working’ version, that’s the only reason I’m using the EOF stuff.

machinegunkelly 06-26-2022 12:51 AM

Quote:

Originally Posted by Publisher Bucks (Post 23015429)
I was under the impression that using <<<EOF was good to use when you have multiple fields to display as far as not having to escape multiple quotes in the code?

This code will actually have several more fields on the page once’s I’ve gotten it to a somewhat ‘working’ version, that’s the only reason I’m using the EOF stuff.

Honestly in all my years Ive never seen EOF, maybe in some old ass smarty bullshit? idk.

So I suspect just listen to konrad!

k0nr4d 06-26-2022 12:58 AM

Quote:

Originally Posted by Publisher Bucks (Post 23015429)
I was under the impression that using <<<EOF was good to use when you have multiple fields to display as far as not having to escape multiple quotes in the code?

This code will actually have several more fields on the page once’s I’ve gotten it to a somewhat ‘working’ version, that’s the only reason I’m using the EOF stuff.

I've went over 20 years now without using that so much as once :1orglaugh
Just use quotes dude. " outer, ' inner for the fields or vice versa.

redwhiteandblue 06-26-2022 01:58 AM

Quote:

Originally Posted by k0nr4d (Post 23015434)
I've went over 20 years now without using that so much as once :1orglaugh
Just use quotes dude. " outer, ' inner for the fields or vice versa.

Indeed. Just use \r\n if you want new lines in your text string.

andy erotic 06-26-2022 08:08 AM

I mean, is no one else going to comment that it's some really, custy-nasty-ass code that really shouldn't be in production or should I be a sycophant?

Klen 06-26-2022 08:38 AM

Quote:

Originally Posted by machinegunkelly (Post 23015404)
I asked last time and Konrad brought up a valid point.

But are you looking to be a hirable PHP dev? if not... look into frameworks man, you're struggling for nothing.

If you desire a job as a PHP dev, ignore me, but if not .. use a framework and skip this bullshit you're suffering through.

I am not using any PHP framework and so far there is nothing what i cant debug it or make it work.

Klen 06-26-2022 08:39 AM

Quote:

Originally Posted by k0nr4d (Post 23015416)
Jesus, just use quotes like a normal human being instead of this << heresy.

Yep, i think i used EOF only when i sucked at coding :1orglaugh

k0nr4d 06-26-2022 08:42 AM

Quote:

Originally Posted by andy erotic (Post 23015508)
I mean, is no one else going to comment that it's some really, custy-nasty-ass code that really shouldn't be in production or should I be a sycophant?

If you check the previous questions we've long given up on that :1orglaugh It honestly looks like he's improving slightly though.

sarettah 06-26-2022 09:21 AM

Just want to say that everybody was a beginner at some point.

.

zijlstravideo 06-27-2022 06:48 AM

Quote:

Originally Posted by Klen (Post 23015515)
I am not using any PHP framework and so far there is nothing what i cant debug it or make it work.

Indeed, it takes more time to read through all info in the docs than to just start writing a few custom functions from scratch.

Quote:

Originally Posted by sarettah (Post 23015528)
Just want to say that everybody was a beginner at some point.

.

Lol, yeah I think we all fucked up a couple of times more than we'd like to admit. :1orglaugh

As a beginner, just be careful with user input when using your own code in production...
It's better to write a paranoid rule for sanitizing user input, just to be safe (such as stripping everything except a-z and 0-9, which is fine for for most cases anyway). :thumbsup

Klen 06-27-2022 06:56 AM

Quote:

Originally Posted by zijlstravideo (Post 23015873)
Indeed, it takes more time to read through all info in the docs than to just start writing a few custom functions from scratch.


It have sense only if framework contain class for something specific , and it helps you to reduce time since it's already made. But i find it annoying how so many people thinks how you are trash if you dont use one :1orglaugh

zijlstravideo 06-27-2022 07:20 AM

Quote:

Originally Posted by Klen (Post 23015874)
It have sense only if framework contain class for something specific , and it helps you to reduce time since it's already made. But i find it annoying how so many people thinks how you are trash if you dont use one :1orglaugh

Yeah, like why would anyone need a fancy framework to pull and write some data to a database. Seems like a complete overkill to me.

I also really dislike digging through other people's code... debugging takes so much more time if you didn't write the code yourself.

Klen 06-27-2022 07:44 AM

Quote:

Originally Posted by zijlstravideo (Post 23015883)
Yeah, like why would anyone need a fancy framework to pull and write some data to a database. Seems like a complete overkill to me.

I also really dislike digging through other people's code... debugging takes so much more time if you didn't write the code yourself.

Lol that is exactly my though about it - if something fails on framework side, then you cant do shit but wait for support to fix it.

machinegunkelly 06-27-2022 08:10 AM

Quote:

Originally Posted by zijlstravideo (Post 23015883)
Yeah, like why would anyone need a fancy framework to pull and write some data to a database. Seems like a complete overkill to me.

I also really dislike digging through other people's code... debugging takes so much more time if you didn't write the code yourself.

My point was that if all he's aiming to do is a make a production ready site, and seems to be learning everything from the ground up. a frame work may come in handy.

As it takes a lot of the absolute bullshit out of raw PHP, that may keep this poor guy developing for years and never producing anything.

XSS prevention, Security, Media files, Image uploads, validation, relationships, etc etc etc, are a lot of work in raw php, and DEAD simple with a framework.

So is he trynna make a site? or trynna learn PHP.

If all he wants to do is make a site, and he has basic PHP Knowledge a framework will take alot of the pain out.

If he wants to learn PHP, have at 'er

blackmonsters 06-27-2022 08:13 AM

Quote:

Originally Posted by Publisher Bucks (Post 23015380)
I'm getting the following error message on a basic newsletter program im putting together, I'm assuming that it may have something to do with additional white/ blank spaces in the code but, I cant find any in the code.



This is the index.php file code:



Any help would be greatly appreciated, I've been fucking with this line 11 issue for the last 30 minutes with no resolve :/


This code runs fine on my server :

PHP Code:

<?php
$title 
"Home!";
$content = <<<EOF
<h3>current stats</h3>
<p>
$users user registered</p>
<p>
$emails subscribers</p>
<p>
$subs newsletter subscriptions</p>
<p>
$nls newsletters</p>
<p>
$mess messages</p>
<p>
$temps templates</p>
EOF;
echo 
$content?>


There seems to be no problem with that code.


:2 cents:

zijlstravideo 06-27-2022 08:27 AM

Quote:

Originally Posted by machinegunkelly (Post 23015898)

As it takes a lot of the absolute bullshit out of raw PHP, that may keep this poor guy developing for years and never producing anything.

:1orglaugh OP does seem to be working on it for ages now... Gotta admire that.

Quote:

Originally Posted by machinegunkelly (Post 23015898)
XSS prevention, Security, Media files, Image uploads, validation, relationships, etc etc etc, are a lot of work in raw php, and DEAD simple with a framework.

So is he trynna make a site? or trynna learn PHP.

If all he wants to do is make a site, and he has basic PHP Knowledge a framework will take alot of the pain out.

If he wants to learn PHP, have at 'er

You're right, OP does seem to always skip the official PHP docs and starts building right away... :pimp So yeah, I guess it makes sense to use a framework when you're just starting out learning PHP and the website needs more than just the basic SQL stuff.

Or perhaps even buying a fully working script and just modify it a bit to your own needs. That's what I often did when I barely knew the basics. Learned a lot that way (with trial and error... lots of error).

machinegunkelly 06-27-2022 08:31 AM

Quote:

Originally Posted by zijlstravideo (Post 23015905)
:1orglaugh OP does seem to be working on it for ages now... Gotta admire that.



You're right, OP does seem to always skip the official PHP docs and starts building right away... :pimp So yeah, I guess it makes sense to use a framework when you're just starting out learning PHP and the website needs more than just the basic SQL stuff.

Or perhaps even buying a fully working script and just modify it a bit to your own needs. That's what I often did when I barely knew the basics. Learned a lot that way (with trial and error... lots of error).

Yea, thats why I asked him.

If I just wanted to build a site, I'd use a framework.

If I wanted to brush up my PHP skills, or master them.. Id not.

but if you just wanna get a site up and running.. and the syntax and fundamentals of PHP are slowing that down, alot of those fundamental problems become very trivial with a framework.

Based on his previous questions, the most likely outcome of him actually producing a live site, from the code he's been doing, is that it's instantly hacked, OR he's gotta spend 6 months learning hot to prevent every possible attack, how to sanitize data etc etc.

He'll NEVER get a site going.

Publisher Bucks 06-27-2022 07:26 PM

Quote:

Originally Posted by blackmonsters (Post 23015900)
This code runs fine on my server :

PHP Code:

<?php
$title 
"Home!";
$content = <<<EOF
<h3>current stats</h3>
<p>
$users user registered</p>
<p>
$emails subscribers</p>
<p>
$subs newsletter subscriptions</p>
<p>
$nls newsletters</p>
<p>
$mess messages</p>
<p>
$temps templates</p>
EOF;
echo 
$content?>

There seems to be no problem with that code.


:2 cents:

Could it be something 'missing' on the server php wise (module perhaps, or is this pretty standard that should already be running?) as to why it isnt working for me? Im still getting the same error message :Oh crap

Publisher Bucks 06-27-2022 07:34 PM

Quote:

Originally Posted by machinegunkelly (Post 23015906)
Yea, thats why I asked him.

If I just wanted to build a site, I'd use a framework.

If I wanted to brush up my PHP skills, or master them.. Id not.

but if you just wanna get a site up and running.. and the syntax and fundamentals of PHP are slowing that down, alot of those fundamental problems become very trivial with a framework.

Based on his previous questions, the most likely outcome of him actually producing a live site, from the code he's been doing, is that it's instantly hacked, OR he's gotta spend 6 months learning hot to prevent every possible attack, how to sanitize data etc etc.

He'll NEVER get a site going.

I set myself a challenge of learning something new this year, PHP was what I chose to learn, if I'm using framework, I'm not really 'learning' anything substantial and I may as well just purchase pre-packed scripts and aplications.

By learning this myself, by hand, I'm actually enhancing my knowledge and have the option (at a later date) of putting something that I've learned into practice.

As far as not getting a site running, I'm already using a lot of what I've learned in the past few months as an ebook spinner and cover generator that has been a huge benefit to my main business, every day it generates as many new titles with covers as needed and they're all making sales each month :winkwink:

So while to some I may be taking the long route, as of right now, it appears to be paying off for me, despite hitting a few roadbumps along the way, but only by trying, asking and understanding where *I* am messing things up, will I actually learn anything and I genuinely do appreciate all of the help and advice (and yes, even criticism) that Ive bene getting for those of you who are more knowledgable about .php than I am at this point in time :thumbsup

machinegunkelly 06-27-2022 09:25 PM

Quote:

Originally Posted by Publisher Bucks (Post 23016116)
I set myself a challenge of learning something new this year, PHP was what I chose to learn


Fair, Thats why I asked what your goal was.

Good luck brother!

Publisher Bucks 06-28-2022 05:45 AM

Quote:

Originally Posted by machinegunkelly (Post 23016128)
Fair, Thats why I asked what your goal was.

Good luck brother!

Thanks :thumbsup

blackmonsters 06-28-2022 06:23 AM

Quote:

Originally Posted by Publisher Bucks (Post 23016112)
Could it be something 'missing' on the server php wise (module perhaps, or is this pretty standard that should already be running?) as to why it isnt working for me? Im still getting the same error message :Oh crap

Download the file from the server, open it and make sure it's exactly what you uploaded.
See if line 11 has all 3 "<".

:2 cents:

vdbucks 06-28-2022 07:13 AM

Why use EOF at all?

https://onlinephp.io/c/ecc2f

Code:

<?php
  require_once 'config.php';
  login_required();
  $users = count_query("SELECT COUNT(*) AS num FROM users");
  $emails = count_query("SELECT COUNT(*) AS num FROM subscribers");
  $subs = count_query("SELECT COUNT(*) AS num FROM subscriptions");
  $nls = count_query("SELECT COUNT(*) AS num FROM newsletters");
  $mess = count_query("SELECT COUNT(*) AS num FROM messages");
  $temps = count_query("SELECT COUNT(*) AS num FROM templates");
  $title = "Home!";

  $content = "
    <h3>current stats</h3>
    <p>{$users} user registered</p>
    <p>{$emails} subscribers</p>
    <p>{$subs} newsletter subscriptions</p>
    <p>{$nls} newsletters</p>
    <p>{$mess} messages</p>
    <p>{$temps} templates</p>
  ";

  include 'layout.php';
?>

More importantly, you should work on your variable structure as conducting 6 different standalone queries like this isn't very efficient. Look into using subqueries instead.

:2 cents:


All times are GMT -7. The time now is 09:30 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123