Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-10-2012, 03:40 AM   PM User | #1
frank5050
New Coder

 
Join Date: Feb 2011
Posts: 32
Thanks: 3
Thanked 0 Times in 0 Posts
frank5050 is an unknown quantity at this point
Problem with seemingly simple query - Help please

I have a database table with a column 'phonecarriers' that has some network names stored in it such as,

phonecarriers
AT&T
Tmobile
Verizon

Some values in the column 'phonecarriers' have ampersand (&) such as AT&T while others don't (TMobile or Verizon)


When I query the database with the follwing query:

$sql="SELECT * FROM table WHERE phone= '$model' and phonecarriers = '$network' ";



I get correct results if $network variable is either TMobile or Verizon.

I do not get results if $network variable is AT&T.

I also get correct results if instead of '$network' , I plug and type network = 'AT&T' directly in the query.


What can I do differently, or how can I write the query so that that when the '$network' variable is AT&T that the query would fetch results from the table where phonecarriers is AT&T.


Any help would be appreciated,
Thanks

Last edited by frank5050; 12-10-2012 at 03:43 AM..
frank5050 is offline   Reply With Quote
Old 12-10-2012, 04:29 AM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,393
Thanks: 18
Thanked 351 Times in 350 Posts
sunfighter is on a distinguished road
How are you defining $network? I don't think the problem is in using an ampersand, because you obtain results with network = 'AT&T'.
sunfighter is online now   Reply With Quote
Reply

Bookmarks

Tags
ampersand, mysql, php, variables

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:00 AM.


Advertisement
Log in to turn off these ads.