Pages: 12Next
Current Page: 1 of 2
$_GET not working when using htaccess wampServer
Posted by: Halialduhoky (185.136.149.---)
Date: August 21, 2017 09:56PM

Hello everyone.
please anyone here to help me! i have the problem just with wampserver!

i have new project and i using htaccess to rewrite the URLs
I'm sure from my code there's nothing wrong in code, today i tested it in xamp and on 000webhost and it's working without any problems yet!

But when i testing the same scripts in wampServer $_GET not working in Php page i get this error ( undefined index ).

The problem is from wampServer server maybe there have something should i change it but i do not know where's the problem exactly.

Please Help Me

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Otomatic (Moderator)
Date: August 21, 2017 10:50PM

Hi,

First READ (and answer) BEFORE YOU ASK A QUESTION

Secondly: what is the exact and complete error message

And, thirdly, if PHP tells you that there is an undefined index, there is really an undefined index; This is an error in your script.

The fact that you see this error with Wampserver comes from the fact that the error handling configurations are different between XAMP or your host and WAMP.
It is up to you to verify this configuration difference.

I repeat, there is an error in your script and nothing will change my mind.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Halialduhoky (185.136.149.---)
Date: August 21, 2017 11:09PM

Hello bro, Thanks for replay smiling smiley

++First READ (and answer) BEFORE YOU ASK A QUESTION
--Sorry for that, But i read before i asking but i don't see anything related my issue.

++Secondly: what is the exact and complete error message
--( ! ) Notice: Undefined index: key in D:\wamp64\www\codersPlatform\examples.php on line 2

++thirdly, if PHP tells you that there is an undefined index, there is really an undefined index; This is an error in your script.
--Bro bro my script just contain
<?php

echo $_GET['key'];

?>

I do not have anything else in page(FOR TESTING) smiling smiley please help me to know from where is the error.

Thanks



Edited 2 time(s). Last edit at 08/21/2017 11:17PM by Halialduhoky.

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: RiggsFolly (Moderator)
Date: August 22, 2017 12:49AM

If this is all there is in your script

<?php
echo $_GET['key'];
?>

Then the first time you run that script it will generate the error because there is no `key` parameter unless you run the script using a querystring with a `key` parameter

i.e.

`example/com/?key=100`


So its a coding error

The correct way to code that is

<?php

if ( isset($_GET['key'] ) {
    echo $_GET['key'];
} else {
    echo 'No parameter given on the query string
}

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Halialduhoky (185.136.149.---)
Date: August 22, 2017 01:13AM

if ( isset($_GET['key'] )) {
echo $_GET['key'];
} else {
echo 'No parameter given on the query string';
}

Now i get this error because the $_GET NOT isset.
No parameter given on the query string

Bro i'm sure the problem is not from php side!
i'm sure is there have something need to change or need to enabled before using RewriteRule.


Please answer this questions i have asking about.
How can i know if ( rewrite module ) is working fine or not?
And what should i disable and enable when i enabling rewrite module to make it working correctly?

And i will ask you something, If the problem is from my script! why it's working when i removing htaccess codes, so here it's makes me sure the problem is from something!


Thanks for replay bro.



Edited 1 time(s). Last edit at 08/22/2017 01:15AM by Halialduhoky.

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: RiggsFolly (Moderator)
Date: August 22, 2017 09:57AM

You mention that you are using a `.htaccess` file and rewriting the url.

But you dont show us the `.htaccess` file?????
But you dont tell use where the `.htaccess` file is located???

All relevant information


As you say this code generates the ELSE message, that says it all. Either you have not put a `key` parameter on your querystring, or the rewrite rules you have written are removing/destroying it.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Halialduhoky (95.170.196.---)
Date: August 22, 2017 01:58PM

Thanks bro for your replaying, i will write for you what i doing exactly from a to z.

Firstly i using wampServer 3.0.6.
Secondly from wamp, apache modules, i enabled ( rewrite module ) but i do not know if is working correctly or not.
Thirdly i using this code for htaccess

--------------------- Htaccess Code ---------------------------
RewriteEngine On
Rule ^examples/([a-zA-Z0-9]{1,30})$ examples.php?key=$1 [QSA,L]
--------------------- Htaccess Code ---------------------------

Fourthly: i using this link:
localhost/cp/examples/somethinghere

Fifthly: i using this php code

--------------------- Php Code ---------------------------
<?php
echo $_GET['key'];
?>
--------------------- Php Code ---------------------------


My project direction is: C:\wamp64\www\cp
i put htaccess in ( CP ) directly.


Thanks again bro for your quick replays.



Edited 1 time(s). Last edit at 08/22/2017 02:03PM by Halialduhoky.

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: RiggsFolly (Moderator)
Date: August 22, 2017 04:12PM

Hi,

I am sorry but debugging your rewrite rules is not our job.
This is not a WAMPServer issue.

Simple test:

1. remove your htaccess file
2. run `localhost/cp/examples.php?key=99`

Does your script echo you the number 99

3. replace your .htaccess file
4. run `localhost/cp/examples/99`

If you do not get 99 echo'd back to you, your .htaccess rewrite rule is wrong.

URL Rewriting is down to you to fix, not us. Its not a WAMPServer issue.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Halialduhoky (95.170.196.---)
Date: August 22, 2017 05:15PM

YES IT'S WORKING WITH `localhost/cp/examples.php?key=99` WHEN I REMOVE HTACCESS.

SIR, IF THE PROBLEM IS FROM MY HTACCESS PLEASE JUST UNDERSTAND ME WHY IT'S WORKING WITH ANOTHER SERVERS?

I THINK THERE HAVE SOMETHING TO CHANGE IT OR THERE HAVE SOMETHING TO ENABLING IT BEFORE USING HTACCESS.

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Otomatic (Moderator)
Date: August 22, 2017 05:39PM

Hi,

> WHY IT'S WORKING WITH ANOTHER SERVERS?
No, it does not work on other servers!
It's just that on other servers, your error is hidden and is not displayed.

Left-Click Wampmanager tray icon -> PHP -> PHP settings -> display_errors

But, even if display_errors is uncheked, your error is in the php_error.log file

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Halialduhoky (185.136.149.---)
Date: August 22, 2017 09:00PM

>No, it does not work on other servers!
bro it's working in other servers without any problems, i'm sure what i said, because I'm not a beginner in programming exactly php.

>Your error is hidden and is not displayed.
Let's say my error is hidden,Ok but why on other server $_GET working without any problem and i get the result of the key.


And please if you know another forums that supported servers give me these links to share my problem there too.

Thanks for your replay bro.



Edited 1 time(s). Last edit at 08/22/2017 09:02PM by Halialduhoky.

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Halialduhoky (185.136.149.---)
Date: August 22, 2017 09:39PM

Bro only i adding this comment for note!

in Htaccess when i try to put this code to convert .php to .html so it's working without any problems in WampServer!

RewriteRule ^examples.html$ examples.php

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Otomatic (Moderator)
Date: August 22, 2017 10:01PM

Hi,

To be able to compare in a reliable and perennial way, the servers that are compared must have:

Same version of Apache installed from the same source
Same Apache modules loaded
Exactly same Apache settings

Same version of PHP installed from the same source
Same PHP extensions loaded
Exactly same PHP settings

And the operating systems on which the servers are running must even be exactly the same.
For the simple reason that the Apache and PHP versions for Windows or for Linux are not compiled with the same compilers.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: RiggsFolly (Moderator)
Date: August 23, 2017 02:02AM

You could try

RewriteRule ^(examples)/?$ example.php?key=$1 [QSA,L]

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Halialduhoky (185.136.149.---)
Date: August 24, 2017 08:06AM

Hey sir, Sorry for delaying, i was outside city.

Bro i think the problem coming from Php version, xampServer php version is 7.1.7 and wamp is 7.0.10, so i try to add new php version to wamp but i get some problems!


first i installing php7.1.8 from php.net from here exactly
[php.net]

then i extract the tar in D:\wamp64\bin\php\ I EXTRACT HERE and i change it name to php7.1.8

I copy (php.ini & phpForApache.ini & wampserver.conf)files from php7.0.10 and i past it in my new php version folder that is 7.1.8

then in php7.1.8 I am modifying these files.
php.ini
phpForApache.ini

in these files i searching for (extension_dir) and i change it to
D:/wamp64/bin/php/php7.1.8/ext/
this dir in php7.0.10 is
D:/wamp64/bin/php/php7.0.10/ext/


But wampServer icon still orange color that doesn't change to green! So there have problem!
Please tell me what should i change more to make wamp server working with new php version.



Note : My Apache version is 2.4.23


And about your htaccess code bro, it's not working, i'm sure what i write in my htaccess the problem is not from my htaccess file never.(I'm sure).



Thanks for replaying.



Edited 1 time(s). Last edit at 08/24/2017 08:09AM by Halialduhoky.

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Otomatic (Moderator)
Date: August 24, 2017 08:33AM

Hi,

> first i installing php7.1.8 from php.net from here exactly
There are times when I really wonder what it's like for me to spend time building addons for all new versions of PHP.

There http://wampserver.aviatechno.net/ you have all the addons - that is, installers to automatically add a version of PHP without changing anything to your Wampserver configuration - for PHP 32 and 64 bit between versions 5.3.5 and 7.1.8. There are 110 versions of PHP!

What also serves as RiggsFolly to make a note on everything concerning Wampserver 3:
WAMPserver 3 - All you need to know

> first i installing php7.1.8 from php.net from here exactly 'http://php.net/get/php-7.1.8.tar.bz2'
In addition, this is not a PHP version for Windows.
PHP versions for Windows are there http://windows.php.net/download/

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Halialduhoky (185.136.149.---)
Date: August 24, 2017 09:17AM

Sir, Dear.

Thanks for your helping.

i download PHP 7.1.8 64 bit x64 addon from here exactly
[wampserver.aviatechno.net]

when i install it i get this message:
----------------------------------------------------
The current version of installed Wampserver is 3.0.6
This addon can only be done on version 3.0.9 or more
install Wampserver 3.0.9 ( or more ) update after cancel this install
----------------------------------------------------
So, I check wampserver.com for wampServer 3.0.9, but i do not find this version!



And about adding php 7.1.8 manually.
i download the php7.0.1 for windows from that link you gives to me.
[windows.php.net]
And i get the same problem! not working when adding it manually

Before i was adding any php version manually without any problems, but now i do not know maybe i forget something to modify it before start to working with the new php version!

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Halialduhoky (185.136.149.---)
Date: August 24, 2017 09:33AM

Bro now php7.1.8 working without anyproblem, not i have php7.1.8 but i also get Undefined index.
So i think the problem is not from php verstion! but it's from php maybe php extensions!

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Otomatic (Moderator)
Date: August 24, 2017 09:38AM

Hi,

> So, I check wampserver.com for wampServer 3.0.9, but i do not find this version!

What also serves as RiggsFolly to make a note on everything concerning Wampserver 3:
WAMPserver 3 - All you need to know

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: $_GET not working when using htaccess wampServer
Posted by: Halialduhoky (185.136.149.---)
Date: August 24, 2017 09:51AM

Did wamp server causing this problem if is old version or new?
If not i do not need to update my wampServer!

Options: ReplyQuote
Pages: 12Next
Current Page: 1 of 2


Sorry, only registered users may post in this forum.