| | |
$_GET
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2007
Posts: 52
Reputation:
Solved Threads: 1
can someone tell me whats wrong with my code?
PHP Syntax (Toggle Plain Text)
$file= "/file.txt"; $search ='/$_GET[word]/i'; echo $search; if (preg_match($search, $file)) { echo "A match was found."; }
You are using single quotes (') for your $search string. Variables aren't parsed inside single quotes. So the search string right now is literally '/$_GET[word]/i'
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
It's a regular expression so the correction would be
php Syntax (Toggle Plain Text)
$search = "/$_GET[word]/i";
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
It works for all letters, you just can't use a variable inside single quotes.
php Syntax (Toggle Plain Text)
$myVar = 'Hello World'; $string = '/$myVar/'; //== /$myVar/ $string = "/$myVar/" //== /Hello World/
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
![]() |
Similar Threads
- Problem with $_GET and JOIN (PHP)
- php relocation on $_Get (PHP)
- phpBB thread archive (PHP)
- BASIC FORM problems... (PHP)
- Help with a script (PHP)
- DLL not woking - Please help me (PHP)
- page.php?page=1,2,3,4,..inf. (PHP)
Other Threads in the PHP Forum
- Previous Thread: dynamic html
- Next Thread: multi column data display
Views: 1057 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date datepart directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link list login loop mail menu methods mlm mod_rewrite multiple mysql oop parse password paypal pdf php problem query radio random recursion regex remote script search select seo server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web webdesign xml youtube






