I am getting [syntax=php]Resource id #7[/syntax] from this query while i am trying to select the posts.
[syntax=php]
$email = mysql_real_escape_string($email);
$r = array();
$r = mysql_query("SELECT
id AS id,
url AS url,
url_key AS url_key,
date AS date,
email AS email
FROM urls WHERE email = '{$email}' ORDER BY date DESC");
while (($row = mysql_fetch_assoc($r)) !== false) {
$r[] = array(
'id' => $row['id'],
'url' => $row['url'],
'url_key' => $row['url_key'],
'date' => $row['date']
);
}
return $r;
[/syntax]
what is the porblem
PHP MySQL Select Query
-
- Posts: 534
- Joined: Thu May 05, 2011 8:19 pm
Re: PHP MySQL Select Query
I think your problem may be stemming from the fact that you're using a keyword as a field header.
Also, why do you do [syntax=sql]id AS id[/syntax] there isnt any need to do that?
[syntax=sql]SELECT `id`,`url`,`url_key`,`date`,`email` FROM `urls` WHERE `email` = {$email} ORDER BY `date` DESC[/syntax]
Try that as your query.
Also, why do you do [syntax=sql]id AS id[/syntax] there isnt any need to do that?
[syntax=sql]SELECT `id`,`url`,`url_key`,`date`,`email` FROM `urls` WHERE `email` = {$email} ORDER BY `date` DESC[/syntax]
Try that as your query.
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ![Wink ;)](./images/smilies/icon_e_wink.gif)
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
![Wink ;)](./images/smilies/icon_e_wink.gif)
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Re: PHP MySQL Select Query
You are using $r for two different things, you will need to give one of them a new name. I would also recommend not using single character variable names, why not do with $rows and $result ![Smile :)](./images/smilies/icon_e_smile.gif)
Also you do need to add the backticks as above![Smile :)](./images/smilies/icon_e_smile.gif)
![Smile :)](./images/smilies/icon_e_smile.gif)
Also you do need to add the backticks as above
![Smile :)](./images/smilies/icon_e_smile.gif)