Jump to content

[SOLVED] Quick question


paulman888888

Recommended Posts

How can i remove all NONE letters and numbers.

Please help

 

<?php
// Insert a row of information into the table "example"
mysql_query("INSERT INTO example 
(name, score) VALUES('" . mysql_real_escape_string(substr($_GET['name'], 0, 13)) . "', '" . mysql_real_escape_string($_GET['score']) . "')") 
or die('Theres an error.# Please try again.#');  
echo "Score Uploaded!#";
?>

Link to comment
Share on other sites

i have my $_name variable and i would like all NONE letters and numbers to be removed.

I thought of this but i havent finshed it because i dont know how.

<?php
$thename=remove_none_letters_and_numbers($_get['name'])// the part i added but dont know how to make work

// Insert a row of information into the table "example"
mysql_query("INSERT INTO example 
(name, score) VALUES('" . mysql_real_escape_string(substr($thename, 0, 13)) . "', '" . mysql_real_escape_string($_GET['score']) . "')") 
or die('Theres an error.# Please try again.#');  
echo "Score Uploaded!#";
?>

 

please help

Link to comment
Share on other sites

Your code:

 

$thename=remove_none_letters_and_numbers($_get['name'])// the part i added but dont know how to make work

 

turns into:

 

$thename = preg_replace ("/[^a-zA-Z0-9]/", "", $_GET['name']);

 

or if you like

 

function clearInvalidChars ($str) {

    return preg_replace ("/[^a-zA-Z0-9]/", "", $str);

}

 

$thename = clearInvalidChars ($_GET['name']);

Link to comment
Share on other sites

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.