Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

What's wrong with this Select statement

I've run into a problem that I can't figure out.

My code is below. It works fine unless my event_category has an apostrophe in it. Then, while the code still fires, there won't be any data associated with that category. I can look in the database and see it, but it won't show up on my page.

What do I have to do in order to accommodate the apostrophe? For example, "Women's Ministry." There's something about "Women/'s Ministry" that's messing things up and I don't know what.

Thoughts?
<?php	
					$querystate = "select distinct event_category from calendar order by event_category";
					$resultstate = mysqli_query($cxn, $querystate)
					or die ("Couldn't execute query.");
				
					while ($row=mysqli_fetch_assoc($resultstate))
					{
					extract($row);
					$the_event_category = $event_category;
					?>
					<tr>
					<td colspan="3" bgcolor="blue">
					<font color="white"><?php echo stripslashes($the_event_category); ?></font>
					</td>
					</tr>
					<?php 						
					$bruce="select * from calendar where event_category = '$the_event_category' order by event_date";
					$bruce_query = mysqli_query($cxn, $bruce)
					or die("Couldn't execute query.");
					while($bruce_row = mysqli_fetch_assoc($bruce_query))
					{
					extract($bruce_row);
					?>
					<tr>
					<td>
					<?php echo date("m/d/y", strtotime($event_date)); ?>
					</td>
					<td>					
					<?php echo stripslashes($event_name); ?>
					</td>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial