php: Why Can't I Query Mysql DB??
Ok, I have a database, set up as follows:
It extracts the data from cities contained in a simcity 4 region. The table I'm interested in-- 'regions', in that DB contains the population numbers for an entire region (per row): id name total_pop total_R total_C total_I vrestrict created modified 1 SimNation_II 2035783 1332966 504280 198537 0 2004-10-22 11:39:39 2004-11-11 03:55:37 Anyways, the code is supposed to connect to mysql, extract these values, and display them, but it returns '0' and NOTHING else for any of the values: http://dyslexitech.com/stats.php Here is the code: Code:
<?php -thanks in advance. |
hi
ry these out!! see that the database is runnig and listening on a specific port for this u can portscan then machine and try browsing ur database from the shell aslo / or any gui regards |
Its running alright :( I checked with phpMyAdmin and also through ssh.
And the mysql port (3306) is open too... any more suggestions? -thanks |
hi there
is this username "root" working fine with PHPmyadmin?? if not try out with blan username and password... regards |
I think I see your problem,
try using: mysql_fetch_array($region) instead of mysql_fetch_row($region) mysql_fetch_array() Returns an array that corresponds to the fetched row and is an extended version of mysql_fetch_row() also try using: {$row['created']} instead of {$region['created']} remember that $row is the array, not $region. mysql_fetch_array() creates an array using $row with each value returned from mysql. see: http://us2.php.net/manual/en/functio...etch-array.php http://us2.php.net/manual/en/function.echo.php Hope this helps... |
THANKYOU so much! :D That did it.
And I was about to give up :cool: And thankyou too masand. :) (BTW, root does work in phpMyAdmin) |
I'd be tempted to set up another mysql user with proper granted permissions pretty soon, and use that for your mysql connection. I have a read-only (select) user and at least one other user with insert etc permissions - save some potential heartache!
|
I think the is a place where you need to put a MYSQL_ASSOC flag to return an associative array (an array with named elements ($a["b"] as opposed to $a[0])
|
All times are GMT -5. The time now is 07:51 PM. |