Jump to content

Preg_Match Never Working


Tenaciousmug

Recommended Posts

I can't ever get this stupid function to work. I do it all the time and try to find other ways around it because I can never get ANY of mine to work.

And then I go to boards and copy theirs to see if they work and they don't.... so I really don't get what I'm doing wrong.

 

$depositamt = $_POST['depositamt'];
if (!preg_match("^[0-9]+$", $depositamt))

 

This is what I have. Well not the whole code, but you get what I'm doing...

Link to comment
https://forums.phpfreaks.com/topic/236271-preg_match-never-working/
Share on other sites

Working until PHP6.. as ereg will be removed!

as is "DEPRECATED as of PHP 5.3.0"

 

If you know RegEx your be fine.. but by your questions i assume you don't know it,

 

$depositamt = $_POST['depositamt'];
if (!preg_match("^[0-9]+$", $depositamt))

 

should be

$depositamt = $_POST['depositamt'];
if (!preg_match('/^[0-9]+$/', $depositamt))

 

translated into English that says

if the following does not match

depositamt must have 1 or more number from the start to the end (nothing else)

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.