mysql - PHP syntax wrong? Outputting Resource id #3 -


<?php $link = mysql_connect('localhost', 'user', 'password'); if (!$link) { die('failed connect mysql: ' . mysql_error()); } $db_selected = mysql_select_db('mysql', $link); if (!$db_selected) {   die ("can\'t use db : " . mysql_error()); } $query = sprintf("select church_id hours           day_of_week = date_format(now(), '%w') ,           curtime() between open_time , close_time",     mysql_real_escape_string($day_of_week),     mysql_real_escape_string($open_time),     mysql_real_escape_string($close_time)); $result = mysql_query($query);  if (!$result) {     $message = 'invalid query: ' .mysql_error() . "\n";     $message .= 'whole query: ' .$query;     die($message); }  while ($row = mysql_fetch_array($result)) {     echo $row['shop_id']; }  mysql_free_result($result); echo "end"; ?> 

i know sql query works copying/pasting phpmyadmin. want script output shop_id or series of shop_ids. right outputs resource id #3. looked how fix , mysql_fetch_array supposed answer. doing wrong?

i'm looking on query , see selecting church_id , want output shop_id, should include in select so:

$query = sprintf("select church_id, shop_id hours day_of_week = date_format(now(), '%w') , curtime() between open_time , close_time",     mysql_real_escape_string($day_of_week),     mysql_real_escape_string($open_time),     mysql_real_escape_string($close_time)); $result = mysql_query($query); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -