Jump to content

apostrophe problem


java12

Recommended Posts

I have a problem comparing surnames from different MySQL tables when the surname field has an apostrophe like O'Neill.

 

The surname from table1 is stored as $name and the surname is selected when it matches the surname field in table2. The lines below work fine until an apostrophe appears.

 

I have tried various things like mysql_real_escape_string, which worked on another issue, but not here. Can anyone suggest where I'm going wrong?

 

<?php
			  
			 // $name is the surname field in table1

			 $query = mysql_query("SELECT * FROM table2 WHERE surname='$name'");
			 while ($row = mysql_fetch_array($query))  {
			 echo "$name<br>";

			 }   

			?>

Link to comment
https://forums.phpfreaks.com/topic/51192-apostrophe-problem/
Share on other sites

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.