Gaming, IT, Multimedia & Music Please use this forum to discuss Gaming, IT, Multimedia & Music. |
|
15th August 2012, 12:53
|
#1
|
Saxperience Post Whore
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI
Saxo VTS
|
Any PHP Gurus (MSSQL Specific Query)
Anyone on here good with PHP?
I'm trying to return the results of a query from an array but it's not playing ball and giving me now results all the time. When run in MSSQL Query analyser the results are displayed so its not the query
__________________
Quote:
Originally Posted by Giraffe
I'm happy being a north easternly smoggie bender.
|
|
|
|
15th August 2012, 14:02
|
#2
|
Newbie
Join Date: Jun 2012
Location: Birmingham
Posts: 27
Car(s): White Saxo 1.1 LX
|
Quote:
Originally Posted by Brettles1986
Anyone on here good with PHP?
I'm trying to return the results of a query from an array but it's not playing ball and giving me now results all the time. When run in MSSQL Query analyser the results are displayed so its not the query
|
Show us the bit of code that you're having trouble with.
|
|
|
15th August 2012, 15:40
|
#3
|
Saxperience Post Whore
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI
Saxo VTS
|
<?php
//connect to a DSN
$conn = odbc_connect('CS_CRM','','');
$Firstname = 'Brett';
$Surname = 'England';
$sql = "SELECT Person_No, Active, Firstname, Surname, nvarusergroup FROM People WHERE Firstname = $Firstname and Surname = $Surname and Organisation_no is not null";
$result=odbc_exec($conn, $sql);
echo "<table id=\"results\">
<tr><th>Person_No</th><th>Active</th><th>Firstname</th><th>Surname</th><th>Usergroup</th>";
while ($row = mssql_fetch_array($result))
{
echo "<tr>";
echo "<td><b>" . $row['Person_No'] . "</b></td>";
echo "<td>" . $row['Active'] . "</td>";
echo "<td>" . $row['Firstname'] . "</td>";
echo "<td>" . $row['Surname'] . "</td>";
echo "<td>" . $row['Usergroup'] . "</td>";
echo "<td><a href=\"edit.php?Person_nO=$row[Person_No]\">Edit</a></td>";
echo "<td><a href=\"delete.php?Person_No=$row[Person_No]\">Delete</a></td>";
}
echo "</tr></table>";
odbc_free_result ($result);
?>
__________________
Quote:
Originally Posted by Giraffe
I'm happy being a north easternly smoggie bender.
|
Last edited by Brettles1986; 15th August 2012 at 16:44.
|
|
|
15th August 2012, 16:30
|
#4
|
Saxperience Post Whore
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI
Saxo VTS
|
Fairly sure I know the issue, the function mssql_fetch_array needs to be replaced with odbc_fetch_array but the version of PHP im using does not have it as a defined function so I need to define the function manually.
__________________
Quote:
Originally Posted by Giraffe
I'm happy being a north easternly smoggie bender.
|
|
|
|
15th August 2012, 16:39
|
#5
|
Newbie
Join Date: Jun 2012
Location: Birmingham
Posts: 27
Car(s): White Saxo 1.1 LX
|
Quote:
Originally Posted by Brettles1986
Fairly sure I know the issue, the function mssql_fetch_array needs to be replaced with odbc_fetch_array but the version of PHP im using does not have it as a defined function so I need to define the function manually.
|
Not entirely sure on that one; try using just mssql functions instead of odbc if odbc_fetch_array isn't available in your version of PHP.
|
|
|
15th August 2012, 16:43
|
#6
|
Saxperience Post Whore
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI
Saxo VTS
|
Quote:
Originally Posted by 0x90
Not entirely sure on that one; try using just mssql functions instead of odbc if odbc_fetch_array isn't available in your version of PHP.
|
I've already coded one page to use ODBC and it makes sense to do it that way rather than storing user details in the actual contents of the PHP pages.
I'll try and find an answer to this and if no avail then will change over to mssql methods.
__________________
Quote:
Originally Posted by Giraffe
I'm happy being a north easternly smoggie bender.
|
|
|
|
15th August 2012, 21:33
|
#7
|
Newbie
Join Date: Jun 2012
Location: Birmingham
Posts: 27
Car(s): White Saxo 1.1 LX
|
Quote:
Originally Posted by Brettles1986
I've already coded one page to use ODBC and it makes sense to do it that way rather than storing user details in the actual contents of the PHP pages.
I'll try and find an answer to this and if no avail then will change over to mssql methods.
|
Alright then, fair enough.
Did you try what you suggested in the first place about adding your own odbc_fetch_array? There's a function that someone has already written on the PHP manual page for it.
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 04:25.
|