Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Thu Apr 01, 2004 5:54 pm
I just need a simple query to see if the mssql works in my php
however it returns Resource id #3
Code: Select all
<?
$host = "10.10.10.5:1433";
$usr = "sa";
$pwd = "sa";
$db = "tms";
$connect = @mssql_connect($host, $usr, $pwd)
or die("Couldn't connect to SQL Server on $host");
$select = @mssql_select_db($db, $connect)
or die("Couldn't open database $db");
$query = "SELECT id_mandet01 FROM tms_mandet01";
// id_mandet = field tms_mandet = table
$result = mssql_query($query);
echo $result;
?>
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Thu Apr 01, 2004 6:01 pm
never mind
Code: Select all
echo "<table>";
foreach(mssql_fetch_array($result) as $key => $value) {
echo "<tr><td>$key</td><td>$value</td></tr>";
}
echo "</table>";
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Thu Apr 01, 2004 6:03 pm
seems to me its doing its job, but I dont see any loops to make it show all the id sources. foreach/while =]
edit - blah, nevermind. i'm always late, what I get for opening 10 different browser windows at once.
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Thu Apr 01, 2004 6:17 pm
Well i am always open for other solutions
Steveo31
Forum Contributor
Posts: 416 Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA
Post
by Steveo31 » Thu Apr 01, 2004 6:35 pm
tim wrote:
edit - blah, nevermind. i'm always late, what I get for opening 10 different browser windows at once.
LOL! I hate that...
I had that problem, I think it was because there were no variables with the row, like tim said, something like
Code: Select all
<?php
//query stuff...
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo $row['variable'];
?>
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Thu Apr 01, 2004 6:37 pm
I hope you did relize that it is MSSQL not MYSQL lol, Thanks for the variant tho
Does php have something called store procedures ?
Last edited by
ol4pr0 on Thu Apr 01, 2004 6:47 pm, edited 1 time in total.
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Thu Apr 01, 2004 6:46 pm
MSSQL does have them.. but i am kinda running differant programs doing alot of things.. ( java with mssql , and php does all the other stuff lol ) however i need to make something simular that can be used with the php.
So if there is some way to simulate store procedures from within php that would be nice
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Thu Apr 01, 2004 6:48 pm
Hmm, not really sure where you're going with this
As stored procedures are just a bunch of commands that are stored on a server, then i suppose the PHP equivilent is functions and/or classes inside included/required files *shrug*
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Thu Apr 01, 2004 7:00 pm
found it thanks... what i was kinda looking for ( sorry if i explained it badly )
Code: Select all
$result = mssql_query("StoredProcedureName ...........
Works great