Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

incorrect PHP code

32 views
Skip to first unread message

nos...@ms.com

unread,
Jan 18, 2018, 6:12:19 AM1/18/18
to
The following PHP code does not work correctly;

<div style="text-align:center"><img
src="scripts/captcha/index.php?<?php echo session_name()?>=<?php echo
session_id()?>" style="vertical-align:middle" /> <input type="text"
name="keystring"><br /><span class="fontsm">(word
verification)</span></div><br />

I believe there is a mismatch in the brackets for the IMG element.

Please could someone tell me what needs to be changed to get it to
work.

Thank you.

Ifrit

unread,
Jan 18, 2018, 6:57:32 AM1/18/18
to

nos...@ms.com

unread,
Jan 18, 2018, 7:02:26 AM1/18/18
to
Can you be specific? I can't see anything obviously wrong with the
code. Thanks.

Ifrit

unread,
Jan 18, 2018, 8:36:58 AM1/18/18
to
Try:

<img src=<?php echo "\"scripts/captcha/index.php?" . session_name() .
"=" . session_id() . "\" ?> style="vertical-align:middle" />

--
Ifrit

Ifrit

unread,
Jan 18, 2018, 8:39:16 AM1/18/18
to
Sorry:
<img src=<?php echo "\" . scripts/captcha/index.php?" . session_name() .

Christoph M. Becker

unread,
Jan 18, 2018, 9:27:06 AM1/18/18
to
On 18.01.2018 at 12:12, nos...@ms.com wrote:

> The following PHP code does not work correctly;

What do you expect the code to do, and what does it do? See also
<http://www.catb.org/esr/faqs/smart-questions.html>.

--
Christoph M. Becker

Ifrit

unread,
Jan 18, 2018, 10:33:30 AM1/18/18
to
Sorry again, the first one was the right one after all.

--
Ifrit

nos...@ms.com

unread,
Jan 18, 2018, 10:51:36 AM1/18/18
to
I tried;

<div style="text-align:center"><img src=<?php echo
"\"scripts/captcha/index.php?" . session_name() . "=" . session_id() .
"\" ?> style="vertical-align:middle" /> <input type="text"
name="keystring"><br /><span class="fontsm">(word
verification)</span></div><br />

and it says;

Parse error: syntax error, unexpected 'vertical' (T_STRING), expecting
',' or ';' in /home/ccompiler12/public_html/feedback.php on line 39

Advice? Thanks.

nos...@ms.com

unread,
Jan 18, 2018, 10:58:06 AM1/18/18
to
On Thu, 18 Jan 2018 15:26:58 +0100, "Christoph M. Becker"
<cmbec...@arcor.de> wrote:

>On 18.01.2018 at 12:12, nos...@ms.com wrote:
>
>> The following PHP code does not work correctly;
>
>What do you expect the code to do, and what does it do? See also
><http://www.catb.org/esr/faqs/smart-questions.html>.

It's for a CAPTCHA verification. It's hosted with GoDaddy. On the old
server, it worked. It's been transferred to a new server, and it
doesn't work.

The PHP spits out the following HTML code;

<img
src="scripts/captcha/index.php?PHPSESSID=331f5041b67145685c5401104c602876"
style="vertical-align:middle" />

So for some reason the IMG element fails to load the image.

Christoph M. Becker

unread,
Jan 18, 2018, 11:19:03 AM1/18/18
to
That's basically fine.

> So for some reason the IMG element fails to load the image.

I'd paste the URL of the image into the browser's address line, and
check the response; particularly the status code, and in case of 200,
I'd check the response body, if necessary with a hex viewer.

By the way, php.general isn't a newsgroup, as far as I know. Did you
mean the php-g...@lists.php.net mailing list?

--
Christoph M. Becker

nos...@ms.com

unread,
Jan 18, 2018, 12:01:35 PM1/18/18
to
There is a USENET group php.general, but it has very few new posts.

Is there a PHP user forum somewhere, on the web?

When I type;

http://c-compiler.com/scripts/captcha/index.php?PHPSESSID=331f5041b67145685c5401104c602876

into MSIE, it says;

Fatal error: Uncaught Error: Call to undefined function
imagecreatefrompng() in
/home/ccompiler12/public_html/scripts/captcha/kcaptcha.php on line 49
( ! ) Error: Call to undefined function imagecreatefrompng() in
/home/ccompiler12/public_html/scripts/captcha/kcaptcha.php on line 49
Call Stack
# Time Memory Function Location
1 0.0000 354104 {main}( ) .../index.php:0
2 0.0002 355304 KCAPTCHA->KCAPTCHA( ) .../index.php:33

So it's not finding function imagecreatefrompng.

The help page for imagecreatefrompng is at;

http://php.net/manual/en/function.imagecreatefrompng.php

How do I get this function working? It seems to be the absence of this
particular function which is the issue.

Christoph M. Becker

unread,
Jan 18, 2018, 12:18:43 PM1/18/18
to
On 18.01.2018 at 18:01, nos...@ms.com wrote:

> On Thu, 18 Jan 2018 17:18:56 +0100, "Christoph M. Becker"
> <cmbec...@arcor.de> wrote:
>
>> I'd paste the URL of the image into the browser's address line, and
>> check the response; particularly the status code, and in case of 200,
>> I'd check the response body, if necessary with a hex viewer.
>>
>> By the way, php.general isn't a newsgroup, as far as I know. Did you
>> mean the php-g...@lists.php.net mailing list?
>
> There is a USENET group php.general, but it has very few new posts.

Ah, thanks. It is not the best idea, though, to cross-post on Usenet. :)

> Is there a PHP user forum somewhere, on the web?

There are plenty available. Use your favorite search engine.

> So it's not finding function imagecreatefrompng.

Ah, that's helpful! Most likely the GD extension is not available on
the server. You can check that with phpinfo()[1]. If the extension is
indeed missing, you may have to contact the server admins.

[1] <http://www.php.net/manual/en/function.phpinfo.php>

--
Christoph M. Becker

nos...@ms.com

unread,
Jan 18, 2018, 12:30:58 PM1/18/18
to
On Thu, 18 Jan 2018 18:18:36 +0100, "Christoph M. Becker"
<cmbec...@arcor.de> wrote:

>> Is there a PHP user forum somewhere, on the web?
>
>There are plenty available. Use your favorite search engine.

Would you be able to recommend one or two good PHP web forums?

>> So it's not finding function imagecreatefrompng.
>
>Ah, that's helpful! Most likely the GD extension is not available on
>the server. You can check that with phpinfo()[1]. If the extension is
>indeed missing, you may have to contact the server admins.
>
>[1] <http://www.php.net/manual/en/function.phpinfo.php>

The GD extension is installed.

Is imagecreatefrompng part of GD? If not, which extension are they
part of?

Thanks for your help.

Christoph M. Becker

unread,
Jan 18, 2018, 12:37:44 PM1/18/18
to
On 18.01.2018 at 18:30, nos...@ms.com wrote:

> On Thu, 18 Jan 2018 18:18:36 +0100, "Christoph M. Becker"
> <cmbec...@arcor.de> wrote:
>
> Would you be able to recommend one or two good PHP web forums?

If in doubt, use <https://stackoverflow.com/>.

> The GD extension is installed.
>
> Is imagecreatefrompng part of GD? If not, which extension are they
> part of?

imagecreatefrompng() is part of GD; either PNG support is missing from
GD (rather unlikely), or the function is disabled via disable_functions[1].

[1] <http://www.php.net/manual/en/ini.core.php#ini.disable-functions>

--
Christoph M. Becker

Thomas 'PointedEars' Lahn

unread,
Jan 18, 2018, 1:08:41 PM1/18/18
to
nos...@ms.com wrote:
^^^^^^^^^^^^^
That is not only not an e-mail address, it is a faked address string for an
*existing* second-level domain. That is a violation of Internet standards
and blatant disregard for netiquette.

<http://www.interhack.net/pubs/munging-harmful/>

*PLONK* (pseudo-address added to killfile)

> On Thu, 18 Jan 2018 17:18:56 +0100, "Christoph M. Becker"
> <cmbec...@arcor.de> wrote:
>>By the way, php.general isn't a newsgroup, as far as I know. Did you
>>mean the php-g...@lists.php.net mailing list?
>
> There is a USENET group php.general, but it has very few new posts.

Bad crosspostings aside, there *might* be a newsgroup php.general that is
provided by the newsserver that *you* are using. It is _not_ a Usenet¹
newsgroup; there is no top-level hierarchy named “php” in Usenet.

See also: <http://en.wikipedia.org/wiki/Usenet>

_______
¹ That is _not_ an abbreviation either.

> Is there a PHP user forum somewhere, on the web?

Yes.

F’up2 poster

--
PointedEars
Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Thomas 'PointedEars' Lahn

unread,
Jan 18, 2018, 1:27:34 PM1/18/18
to
Christoph M. Becker wrote:

> On 18.01.2018 at 18:30, nos...@ms.com wrote:
>> On Thu, 18 Jan 2018 18:18:36 +0100, "Christoph M. Becker"
>> <cmbec...@arcor.de> wrote:
>>
>> Would you be able to recommend one or two good PHP web forums?
>
> If in doubt, use <https://stackoverflow.com/>.

JFTR:

Stack Overflow is _not_ a Web forum, but a Q&A site. This is important
because people tend to abuse Stack Overflow as if it were a Web forum,
to their and other user’s disadvantage.

At this time, I cannot recommend using any particular PHP Web forum. I
started learning PHP about 15 years ago with help from of SELFHTML.DE’s PHP
forum (has nothing to do with SELFHTML). It is still online, but apparently
read-only since 2015-04-07; it used to be good when I was still a moderator
there, so some postings there might still be useful.

[de] <http://www.selfhtml.de/forum/forum_4_0.php>

Jerry Stuckle

unread,
Jan 18, 2018, 10:00:39 PM1/18/18
to
On 1/18/2018 12:30 PM, nos...@ms.com wrote:
> On Thu, 18 Jan 2018 18:18:36 +0100, "Christoph M. Becker"
> <cmbec...@arcor.de> wrote:
>
>>> Is there a PHP user forum somewhere, on the web?
>>
>> There are plenty available. Use your favorite search engine.
>
> Would you be able to recommend one or two good PHP web forums?
>

No good web forums, but this newsgroup is pretty good - despite a couple
of trolls. Activity level isn't high but there are a few good people
who are willing to help out.

>>> So it's not finding function imagecreatefrompng.
>>
>> Ah, that's helpful! Most likely the GD extension is not available on
>> the server. You can check that with phpinfo()[1]. If the extension is
>> indeed missing, you may have to contact the server admins.
>>
>> [1] <http://www.php.net/manual/en/function.phpinfo.php>
>
> The GD extension is installed.
>
> Is imagecreatefrompng part of GD? If not, which extension are they
> part of?
>
> Thanks for your help.
>

create a file:

<?php phpinfo(); ?>

Load it into your directory with a .php extension and load it in your
browser. This will show you all of the PHP options. Look for GD
support first. If that's there, then look for png support under GD.

Also are you sure the png file you are referencing is a valid png?

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstu...@attglobal.net
==================

Jerry Stuckle

unread,
Jan 18, 2018, 10:06:30 PM1/18/18
to
On 1/18/2018 12:30 PM, nos...@ms.com wrote:
Another question - what code do you have that's calling
imagecreatefrompng? Why can't you use the png directly?

inigoj...@gmail.com

unread,
Jan 23, 2018, 2:07:42 AM1/23/18
to
In your security code, in the login failed section you could change: $failed = 1; header("location:index.php");. to: $failed = 1; include "./login.php";. That way, when authentication fails, the user will be returned to the login screen without a 301 redirect in-between. php training in chennai

Jerry Stuckle

unread,
Jan 23, 2018, 7:52:33 AM1/23/18
to
On 1/23/2018 2:07 AM, inigoj...@gmail.com wrote:
> In your security code, in the login failed section you could change: $failed = 1; header("location:index.php");. to: $failed = 1; include "./login.php";. That way, when authentication fails, the user will be returned to the login screen without a 301 redirect in-between. php training in chennai
>

Which has nothing to do with the problem at hand and can cause other
problems. This post right here is enough to know not to ever recommend
any of your training classes. Not to mention that you're a SPAMMER.

careenj...@gmail.com

unread,
Mar 6, 2018, 4:49:43 AM3/6/18
to
Besant Technologies Chennai & Bangalore you will be able to get vast experience by transforming your ideas into actual new application and software controls for the websites and the entire computing enterprise.
https://www.besanttechnologies.com/hadoop-training-in-marathahalli

Arno Welzel

unread,
Sep 5, 2018, 3:40:46 AM9/5/18
to
nos...@ms.com:
Then you have to check, why the URL

scripts/captcha/index.php?PHPSESSID=331f5041b67145685c5401104c602876

does not work. Maybe you forgot a slash at the beginning and it should be:

/scripts/captcha/index.php?PHPSESSID=331f5041b67145685c5401104c602876



--
Arno Welzel
https://arnowelzel.de
https://de-rec-fahrrad.de
http://fahrradzukunft.de
0 new messages