Re: PHP/mysql equivalent of PEAR's tableInfo()??

From: Date: Sun, 12 Jul 2009 21:49:42 +0000
Subject: Re: PHP/mysql equivalent of PEAR's tableInfo()??
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-295301@lists.php.net to get a copy of this message
On Sat, Jul 11, 2009 at 19:57, Govinda<govinda.webdnatalk@gmail.com> wrote:
I have been using PEAR's tableInfo() to remind myself about the columns in the table.. but now I want to see as much data as possible about the table and its contents *without* using PEAR. (I.e. just using built in stuff for mysqli.)
This is not mysqli_#() directly, but just mocked up here in this email. Not guaranteed to work, but should give you the right idea at least. ;-P <?php include('inc/config.php'); // Your configuration include('inc/db.php'); // Your database connection info $sql = "SHOW TABLES"; $result = mysql_query($sql); foreach(mysql_fetch_assoc($result) as $k => $v) {
       $ssql = "DESCRIBE ".mysql_real_escape_string($v);
       $rresult = mysql_query($ssql);
       echo "<b>".$k."</b>:<br />\n";
       echo "<pre>\n";
       print_r(mysql_fetch_assoc($rresult));
       echo "</pre>\n";
       echo "<br />\n";
} ?>
Dan I get roughly the idea, but alas I am stumped so easily in this new ocean.. it frustrates me. I have this code: $db_billing=mysqli_connect(localhost,metheuser,mypass,billing); if (mysqli_connect_error()) { die("Can't connect: " . mysqli_connect_error()); } //$dbname = 'billing'; $sql = "SHOW TABLES"; $result = mysql_query($sql); // line 53 foreach(mysql_fetch_assoc($result) as $k => $v) { // line 55 $ssql = "DESCRIBE ".mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo "<b>".$k."</b>:<br />\n"; echo "<pre>\n"; print_r(mysql_fetch_assoc($rresult)); echo "</pre>\n"; echo "<br />\n"; } Which is just giving these errors: Warning: mysql_query() [function.mysql-query]: Access denied for user 'meee'@'localhost' (using password: NO) in /home/meee/public_html/somedir/test.php on line 53 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/meee/public_html/somedir/test.php on line 53 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/meee/public_html/somedir/test.php on line 55 Warning: Invalid argument supplied for foreach() in /home/meee/public_html/somedir/test.php on line 55 -- I am looking forward to when I have enough of my bearings that I can just cruise around all the various docs and figure out my own answers. Now there are just so many unknowns, I often can't tell which way to even look to solve the issues. -G

« previous php.general (#295301) next »