S
S
SeiLove2016-03-29 11:16:16
PHP
SeiLove, 2016-03-29 11:16:16

How is a SQL query made with a dash in a variable?

Good afternoon! Strange problem! At me values ​​in the table are stored with a dash. Let's say 00-0000001. When I make a query in the database directly, everything works! But when I try to apply from php, no! I copy the same request and nothing. It works without variables ... maybe there is some trick?

$user=addslashes($user);
  $query1 = "SELECT * FROM `cat` WHERE `id` like '".$user."'";    
          $result1 = mysql_query($query1);

I also tried using mysql_real_escape_string, didn't help...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DarkMatter, 2016-03-29
@darkmatter

$one = 10;
$two = 111111;
$all = $one.'-'.$two;
"SELECT * FROM `cat` WHERE `id` like '".$all."'";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question