Jump to content

How is the # handled in mysql?


atl_andy

Recommended Posts

I have a table with several records the have a # in their fields.  e.g., PU923AW#ABA.  I use a select statement that matches based on that value, and it pulls two other fields with it to display on a form.  The problem is when that record is chosen, it only pulls one field and not the others.  Do # have to be escaped when they are inserted into a mysql db?

 

-------------------------------------------

Part Number    |  MFR  | Model/Description |

-------------------------------------------

PB-G4PM1.7    | APPLE  | POWER BOOK G4  |  This will pull the Part Number, MFR and Model ok

-------------------------------------------

PU923AW#ABA |  HP      |    NC6220          |  This will only pull the Part Number, and the MFR and Model fields are blank, which makes

-------------------------------------------      me think the problem is with the # in the part number.

 

The select statement being used:

$selected = $_GET['partnumber'];

$result = mysql_query("SELECT * FROM partnumber WHERE partnumber = ' ".$selected." ';

Link to comment
https://forums.phpfreaks.com/topic/101745-how-is-the-handled-in-mysql/
Share on other sites

# in a querystring will give you problems as it used to go to a named anchor point on a page.

 

<?php
$partno = 'PU923AW#ABA';

echo "<a href='mypage.php?part=$partno'>click</a>";         // got problems!!!

$p = urlencode($partno);

echo "<a href='mypage.php?part=$p'>click</a>";              // should be OK

?>

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.