php - cannot select a row in mysql -
edit1 : used double quotes , single quotes getting same error.
edit2 : same query returning me result in mysql shell
i selecting row table.
if(!isset($_get['title']) || !isset($_get['user'])){ echo "hi"; //something come here } else{ $title = $_get['title']; $title = mysqli_real_escape_string($conn,$title); $user = $_get['user']; $user = mysqli_real_escape_string($conn,$user); echo $title ; echo $user ; // tried giving value directly test no luck $query = "select * site client=\"chaitanya\" && title=\"werdfghb\" "; $result5 = mysqli_query($conn,$query) or die(mysqli_error()); $count = mysqli_num_rows($result5); echo $count ; while($result9 = mysqli_fetch_array($result5)){ $kk=$result9['url']; echo $kk ; } $page = $kk; include ( 'counter.php'); addinfo($page); }
in database there row columns title , client , values entered in row when echo count(no of rows)
showing zero
.
is there wrong code ?
the error getting due line
$page = $kk;
in code $kk
not declared previously. defined $kk
in while loop scope.
declare variable in outer scope while loop
... $kk = null; while($result9 = mysqli_fetch_array($result5)) { $kk = $result9['url']; echo $kk ; } $page = $kk; ...
error on fetching data
you have crack sql smaller pieces , test code this.
- run query
select * site
withoutwhere
, count - run query
select * site client='chaitanya'
, count select * site title='werdfghb'
, check count- then run whole query
and see results. way u can find out in issue in sql code. i prefer use mysql client execute queries