Jump to content

Problem with select query!


demon_athens

Recommended Posts

I am really stuck here. I have this script

 

$tt = "Α\' threemonth";
$results = "SELECT * FROM `content` WHERE `sname` = '$tt' "; 
					 // echo "query= ".$results;
					      $results = @mysql_query ($results) or die(mysql_error());
					      $row_results = mysql_fetch_assoc($results);
					      $totalRows_results = mysql_num_rows($results);
						 echo "<br><br>FOUND ".$totalRows_results;

problem is that I get 0 results although I have at least one. The "\'" is causing the trouble. I have exactly the same in my database "Α\' threemonth". How I can make this query works?

Link to comment
Share on other sites

Have you tried running the query in phpMyAdmin (if available) with the string written in. See if you get a result that way. If the original string was added using mysql_real_escape_string() use the same function on your string before attempting to query the db, rather than just putting the single quote in place.

Link to comment
Share on other sites

I tried all this. I really can't understand this. I have enabled error_reporting but its clear of errors.

 

Anyway I tried to see how phpmyadmin creates the php query. Look at this!

 

$sql = 'SELECT * FROM `content` WHERE `sname` = CONVERT(_utf8 \'Α\\\\\'\' threemonth\' USING greek) COLLATE greek_general_ci';

 

 

Link to comment
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.