TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 12-04-2008, 10:38 PM   #1 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default need help with retrieving

I've used this code before, and has worked. But now I can't understand what is the problem.

I have a code to test my queries for a website I am doing. This is the code:

PHP Code:
$a=array();
try{
    
$q=mysql_query('SELECT ArticleID FROM articles') or die(mysql_error());
    echo 
mysql_affected_rows();
    echo 
'<br />';
    
var_dump($q);
    echo 
'<br />';
    while(
$res=mysql_fetch_assoc($q));
        
array_push($a$res);
    
var_dump($a);
    echo 
'<br />';
}catch(
Exception $e){
  echo 
$e->getMessage();
  exit();

the echo and var_dump statements I used them to see what is the problem, but still can't figure out. The output I get is this:

Code:
8
resource(15) of type (mysql result)
array(1) { [0]=> bool(false) }
I know I have 8 entries in the table, because I also ran the query in the mysql console and got this:

Code:
mysql> SELECT ArticleID FROM articles;
+----------------------------------+
| ArticleID                        |
+----------------------------------+
| 32d9b19297370a3f53f22d5d5715c847 | 
| 35d97569c36ade68499ea6f51d88a20a | 
| 6981086eb26c319ad7631b7d2f30618d | 
| 81967e633319c72e44284884157ad432 | 
| 874820c3267d7f0a94bf9a89baf83508 | 
| a7b39088eb9a13de840383ff27e24ac4 | 
| cf47d07a4f6d371f863a41e8e24bc285 | 
| e13d693f6ecd117aeb5ad9d04324e558 | 
+----------------------------------+
8 rows in set (0.00 sec)
I still don't know why I don't get an array of arrays that are the fetched rows. any idea?

If you need more info this is the articles table:

Code:
mysql> SHOW COLUMNS FROM articles;
+-------------+--------------+------+-----+---------+-------+
| Field       | Type         | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| ArticleID   | varchar(32)  | NO   | PRI | NULL    |       | 
| Title       | varchar(255) | NO   |     | NULL    |       | 
| Description | text         | YES  |     | NULL    |       | 
| Content     | text         | NO   |     | NULL    |       | 
| MediaID     | varchar(32)  | NO   | UNI | NULL    |       | 
| UserID      | varchar(32)  | NO   |     | NULL    |       | 
| DateTime    | datetime     | NO   |     | NULL    |       | 
+-------------+--------------+------+-----+---------+-------+
7 rows in set (0.00 sec)
This used to be simple to me, but now it is stressing me out and delaying the final product. thanks for the help in advance.
tony is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieving data KingOfTheSouth MySQL & Databases 11 12-02-2008 07:10 AM
Retrieving Files from a Backup in Vista CMellor The Lounge 2 06-24-2008 02:34 PM
Sending and Retrieving Data WinSrev Javascript, AJAX, E4X 11 02-18-2008 12:18 AM
Interfaces Revisited Karl Advanced PHP Programming 5 11-15-2007 02:40 PM


All times are GMT. The time now is 11:55 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design