Author Topic: view all db info  (Read 615 times)

0 Members and 1 Guest are viewing this topic.

Offline aebstractTopic starter

  • Devotee
  • Posts: 1,103
    • View Profile
view all db info
« on: February 11, 2010, 11:23:23 AM »
I've never worked in microsoft sql, so I am not sure if it is in any way similar to mysql or completely different. I'm also somewhat limited on support and what I have access to. I can run php and have full ftp access. I can probably run .net as well, as the site is running on dotnetnuke and from what I've read that is based off of .net. I have no idea whatsoever how to even look at .net, so I would prefer staying with php.

Is there a way to use the sql server info and view all database information? I hope it is structured somewhat similar to mysql, as in having tables, columns/rows, etc. I don't know what tables I have, don't know anything really. I'm going to have to start working on a huge port out and port in to a new system (which will be mysql) and this is my first step. Any advice/info/tips is awesome. Thanks!
There is an area of the mind that could be called unsane, beyond sanity, and yet
not insane. Think of a circle with a fine split in it. At one end there's
insanity. You go around the circle to sanity, and on the other end of the
circle, close to insanity, but not insanity, is unsanity.

Offline Mchl

  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,582
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • FlingBits
Re: view all db info
« Reply #1 on: February 11, 2010, 11:35:29 AM »
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Flingbits tutorials | Class Autoloading

Offline aebstractTopic starter

  • Devotee
  • Posts: 1,103
    • View Profile
Re: view all db info
« Reply #2 on: February 11, 2010, 12:03:48 PM »
Okay, I'm sort of stuck on actually displaying the information.
Code: [Select]
<?php

$server 
'1';

$link mssql_connect($server'2''3');

if (!
$link) {
    die(
'Something went wrong while connecting to MSSQL');
}

$query mssql_query("SELECT * FROM information_schema.tables");
while(
$r=mssql_fetch_array($query))
{

echo 
mssql_result($query);

}




?>


Blank page, I'm assuming I'm connected as I get no error and this is the method that was used as demonstration in the php manual. So that brings me to actually displaying the information, which I usually would do a while and loop through each row of information in a table, though this is obviously different and I'm not looping through like that. How can I echo out the information so I can see it?
There is an area of the mind that could be called unsane, beyond sanity, and yet
not insane. Think of a circle with a fine split in it. At one end there's
insanity. You go around the circle to sanity, and on the other end of the
circle, close to insanity, but not insanity, is unsanity.

Offline Mchl

  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,582
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • FlingBits
Re: view all db info
« Reply #3 on: February 11, 2010, 12:07:59 PM »
How about

while($r=mssql_fetch_array($query))
{

print_r($r);

}
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Flingbits tutorials | Class Autoloading

Offline aebstractTopic starter

  • Devotee
  • Posts: 1,103
    • View Profile
Re: view all db info
« Reply #4 on: February 11, 2010, 12:37:20 PM »
Isn't print_r suppose to format the array nicely so you can look at it and it make sense? Cause this is displaying like a paragraph, and there is a LOT of information. If nothing else, this at least gets me that information! Thanks


EDIT: was thinking of <pre> thanks a lot!
« Last Edit: February 11, 2010, 12:39:00 PM by aebstract »
There is an area of the mind that could be called unsane, beyond sanity, and yet
not insane. Think of a circle with a fine split in it. At one end there's
insanity. You go around the circle to sanity, and on the other end of the
circle, close to insanity, but not insanity, is unsanity.

Offline Mchl

  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,582
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • FlingBits
Re: view all db info
« Reply #5 on: February 11, 2010, 12:42:05 PM »
This is array formatted nicely. You just have to view source to see it ;)
I used print_r only as an example. $r is an array, and you can display it however you wish. You can also save results to a file, for future reference.
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Flingbits tutorials | Class Autoloading