Jump to content

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)

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.