bigashish123 Posted June 10, 2009 Share Posted June 10, 2009 Okay MySQL Gurus - I need your help please! I have this code and it returns no results when I run within PHP. When I run the code in my backend PHP Admin tool, the code executes perfectly. I think it has to do with the Apostrophes I have within the query (i.e., Men's Wedding Ring, Women's Wedding Ring, etc). The double Apostrophes I have in my code below works in my backend MySQL Admin tool but within this PHP code, I return no results. Can I not use double apostrophes ('') within this php code?? Can someone PLEASE tell me what I am doing wrong?? Thank you!!! <?php $connect = mysql_connect("IPAddress", "username", "password") or die ("Hey loser, check your server connection."); mysql_select_db("dbname"); // Get all the data from the "example" table $quey1="SELECT distinct ProductID, Productname, Brand, CONCAT('$',MIN(ABS(SUBSTRING_INDEX(Price,'$',-1)))) AS Price, imageURL, Category, buyURL, LongDesc FROM JewelryStore WHERE Category LIKE '%Classic Solitaire Setting%' or Category LIKE '%Collections::Classic Solitaires%' or Category LIKE '%Collections::Sidestone%' or Category LIKE '%Collections::Vintage%' or Category LIKE '%Five-Stone Setting%' or Category LIKE '%Gemstone Ring%' or Category LIKE '%Gold Wedding Band for Women%' or Category LIKE '%Gold Wedding Bands for Men%' or Category LIKE '%Men''s Wedding Ring%' or Category LIKE '%Pre-set Engagement Ring%' or Category LIKE '%Setting with Sidestones%' or Category LIKE '%Three-Stone Diamond Rings%' or Category LIKE '%Three-Stone Setting%' or Category LIKE '%Women''s Diamond Ring%' or Category LIKE '%Women''s Wedding Ring%' GROUP BY ProductID order by Price ASC"; $result=mysql_query($quey1) or die(mysql_error()); ?> <table class='reference' cellspacing='0' cellpadding='0' border='1' width='100%'> <tr> <th>Ring Image</th> <th>Ring Name</th> <th>Price</th> <th>Ring Description</th> </tr> <?php while($row = mysql_fetch_array( $result )) { echo "<tr>"; echo "<td>"; /* echo '<img src="' . $row['imageURL'] . '"/>';*/ echo '<a href="' .$row['buyURL']. ' "/ target="_new"/> <img src="' . $row['imageURL'] . '"/ border="no"/>'; echo "</td>"; echo "<td>"; echo '<a href="' .$row['buyURL']. ' "/ target="_new"/>'; echo $row['name'] ; echo "</td>"; echo "<td>" . $row['Price'] . "</td>"; echo "<td>" . $row['LongDesc'] . "</td>"; echo "</tr>"; } echo "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/161682-apostrophes-in-mysql-select-query/ Share on other sites More sharing options...
gassaz Posted June 10, 2009 Share Posted June 10, 2009 For me you are right it's becase Apostrophes .. In vb i used this to correct that problem Replace(TXT_PRI.Text, "'", "\'") I don't know commands of string manipulation en php sorry... Quote Link to comment https://forums.phpfreaks.com/topic/161682-apostrophes-in-mysql-select-query/#findComment-853189 Share on other sites More sharing options...
Ken2k7 Posted June 11, 2009 Share Posted June 11, 2009 I believe you have an error in the '%Women''s part. See the double ' between the n and s? Quote Link to comment https://forums.phpfreaks.com/topic/161682-apostrophes-in-mysql-select-query/#findComment-853506 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.