On Jul 13, 2009, at 2:58 PM, Daniel Brown wrote:
On Mon, Jul 13, 2009 at 16:53, Govinda<govinda.webdnatalk@xxxxxxxxx>
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
:-)
Here is the gifted code:
$db_billing=mysql_connect(localhost,metheuser,mypass,billing);
if (!$db_billing) { die('Could not connect: ' . mysql_error()); }
$sql = "SHOW TABLES";
$result = mysql_query($sql) or die(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.
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 72
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php