Jump to content


Photo

database problem-mysql_fetch_object()


  • Please log in to reply
4 replies to this topic

#1 firelior

firelior
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 06 October 2006 - 03:53 PM

Hi,
I have this:
SELECT * FROM cars WHERE `area` LIKE '%ירושלים%'
which is in hebrew.
now. when I enter this through the phpmyadmin I don't get any error but when I do this:
$sql="SELECT * FROM cars WHERE `area` LIKE '%ירושלים%'";
$result = mysql_query($sql);
while ($row = mysql_fetch_object($result))
{
      echo $row->id;
}
I get this error:
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource
Please help.
THANKS

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 06 October 2006 - 03:57 PM

OK, I'd have thought that the query failed... Try this:

$sql="SELECT * FROM cars WHERE `area` LIKE '%ירושלים%'";
$result = mysql_query($sql) or die ("Couldn't execute $sql: " .mysql_error());

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 06 October 2006 - 04:00 PM

might want to try and escape out the value before the query

$value = mysql_real_escape_string("ירושלים");
$sql="SELECT * FROM cars WHERE `area` LIKE '%$value%'";

Ray


#4 firelior

firelior
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 06 October 2006 - 04:11 PM

ok,
huggy: what it does is this:
Couldn't execute SELECT * FROM cars WHERE `area` LIKE '%ירושלים%': Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation 'like'

and ray..it doesn't work. its still the same

#5 firelior

firelior
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 06 October 2006 - 04:50 PM

found the problem..
i just changed the field type to varBINARY




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users