Jump to content

Recommended Posts

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>";


?>

Link to comment
https://forums.phpfreaks.com/topic/161682-apostrophes-in-mysql-select-query/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.