Mobile Devices: Lite Theme Citroën: Citroën Trader | Saxo Trader | C2 Trader Peugeot: Peugeot Trader | 106 Trader Enthusiast: Saxperience


Go Back   Saxperience - Citroen Saxo Forum > Other... > Gaming, IT, Multimedia & Music
Register Member Photo AlbumsBlogs FAQ Calendar Experience

Gaming, IT, Multimedia & Music Please use this forum to discuss Gaming, IT, Multimedia & Music.

Reply
 
Thread Tools Display Modes
Old 15th August 2012, 12:53   #1
Brettles1986
Saxperience Post Whore
South Wales Region Member
 
Brettles1986's Avatar
 
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI Saxo VTS
Brettles1986 is on a distinguished road
Default 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 View Post
I'm happy being a north easternly smoggie bender.
Brettles1986 is offline   Reply With Quote
Old 15th August 2012, 14:02   #2
0x90
Newbie
 
0x90's Avatar
 
Join Date: Jun 2012
Location: Birmingham
Posts: 27
Car(s): White Saxo 1.1 LX
0x90 is on a distinguished road
Default

Quote:
Originally Posted by Brettles1986 View Post
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.
0x90 is offline   Reply With Quote
Old 15th August 2012, 15:40   #3
Brettles1986
Saxperience Post Whore
South Wales Region Member
 
Brettles1986's Avatar
 
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI Saxo VTS
Brettles1986 is on a distinguished road
Default

<?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 View Post
I'm happy being a north easternly smoggie bender.

Last edited by Brettles1986; 15th August 2012 at 16:44.
Brettles1986 is offline   Reply With Quote
Old 15th August 2012, 16:30   #4
Brettles1986
Saxperience Post Whore
South Wales Region Member
 
Brettles1986's Avatar
 
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI Saxo VTS
Brettles1986 is on a distinguished road
Default

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 View Post
I'm happy being a north easternly smoggie bender.
Brettles1986 is offline   Reply With Quote
Old 15th August 2012, 16:39   #5
0x90
Newbie
 
0x90's Avatar
 
Join Date: Jun 2012
Location: Birmingham
Posts: 27
Car(s): White Saxo 1.1 LX
0x90 is on a distinguished road
Default

Quote:
Originally Posted by Brettles1986 View Post
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.
0x90 is offline   Reply With Quote
Old 15th August 2012, 16:43   #6
Brettles1986
Saxperience Post Whore
South Wales Region Member
 
Brettles1986's Avatar
 
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI Saxo VTS
Brettles1986 is on a distinguished road
Default

Quote:
Originally Posted by 0x90 View Post
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 View Post
I'm happy being a north easternly smoggie bender.
Brettles1986 is offline   Reply With Quote
Old 15th August 2012, 21:33   #7
0x90
Newbie
 
0x90's Avatar
 
Join Date: Jun 2012
Location: Birmingham
Posts: 27
Car(s): White Saxo 1.1 LX
0x90 is on a distinguished road
Default

Quote:
Originally Posted by Brettles1986 View Post
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.
0x90 is offline   Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 21:46.