Re: trying to dump out table info
| From: | Govinda | Date: | Mon, 13 Jul 2009 21:24:46 +0000 |
| Subject: | Re: trying to dump out table info | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46292@lists.php.net to get a copy of this message | ||
On Jul 13, 2009, at 2:58 PM, Daniel Brown wrote:
On Mon, Jul 13, 2009 at 16:53, Govinda<govinda.webdnatalk@gmail.com> wrote::-)Hi all I am not sure why this is failing/giving error. I am quite new at PHP/Mysql, and apologize for what will undoubtedly end up being a trivial error on my part.Hey, I recognize that code.... ;-P
when I make that change, it returns this: "No database selected" so I try to modify like this: $db_billing=mysql_connect(localhost,metheuser,mypass,billing); if (!$db_billing) { die('Could not connect: ' . mysql_error()); } $sql = "SHOW TABLES FROM billing LIKE 'myTable'"; $result = mysql_query($sql) or die(mysql_error()); foreach(mysql_fetch_assoc($result) as $k => $v) { //line 64 //{DESCRIBE | DESC} tbl_name [col_name | wild] //$ssql = "DESCRIBE ".mysql_real_escape_string($v); $ssql = "DESCRIBE myTable ".mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo "<b>".$k."</b>:<br />\n"; echo "<pre>\n"; print_r(mysql_fetch_assoc($rresult)); //line 71 echo "</pre>\n"; echo "<br />\n"; } and now the script returns this: Tables_in_billing (myTable): Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/meee/public_html/somedir/test.php on line 72Here is the gifted code: $db_billing=mysql_connect(localhost,metheuser,mypass,billing); if (!$db_billing) { die('Could not connect: ' . mysql_error()); }Note the addition to the $result definition. This will cause the script to exit with the MySQL error message (if any) if the issue is in the query.$sql = "SHOW TABLES";$result = mysql_query($sql) or die(mysql_error());