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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 13, 2009 at 3:19 AM, Govinda <govinda.webdnatalk@xxxxxxxxx>wrote:

> On Sat, Jul 11, 2009 at 19:57, Govinda<govinda.webdnatalk@xxxxxxxxx>
>> 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()); }



mysqli


>
>        //$dbname = 'billing';
>        $sql = "SHOW TABLES";
>
>        $result = mysql_query($sql); // line 53
>

Now mysql, What are you doing?


>
>        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
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Zareef Ahmed :: A PHP Developer in India ( Delhi )
Homepage :: http://www.zareef.net

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux