Jump to content

Recommended Posts

Hi everyone

I have a bit if an issue with some PHP i;ve been playing with.

The following code is working fine to delete data from the database

if (isset($_GET['p'])){
           $namecheck = mysql_query("SELECT `name` FROM `store` WHERE `name` = '".$_GET["p"]." '");
          $count = mysql_num_rows($namecheck);
       
           if ($count !== 0){
                if ($_GET['sure'] === '1'){
                        mysql_query("DELETE FROM `store` WHERE `name` = '".$_GET["p"]."' LIMIT 1");
                }else{
                   echo '<font size="2" color="#ff0000">Are you sure you want to delete this retailer? <a href="deleteretailer.php?p='.$_GET['p'].'&sure=1">Yes</a> or <a href="deleteretailer.php">No</a></font>';
               }
           }
      } 

However if the name contains a & character such as A & B Engineering the echo message doesn't show and I can't delete the data from the database. Is the & character causing an issue as it only seems to affect those names containing it.

 

Thanks

 

B

Link to comment
https://forums.phpfreaks.com/topic/275973-doea-a-character-interfere-with-php/
Share on other sites

The "&" is a separator for GET values. So you have to use urlencode when creating the url string. The other thing you should do is clean the GET value before you submit it to the database. Just type in Google "PHP How to prevent SQL Injections". You willl see a million sites detailing how to make data safe for inserting in to your database.

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.