Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I'm a newbie, forgive me.
I am working on PHP to conenct to a SQL Server database and extract data from a Table.
This is probably pretty simple, but not for me.
I am using some manuals to stumble along ("PHP, MySQL, and Apache" and "Teach Yourself PHP in 10 Minutes" by Sams).
From these books, I know I have to:
1) connect to the server
2) connect to the database
3) select the data from the table
1) instead of $db = mysql_connect ("X","X","X") what should I use to connect the SQL Server?
2) again, instead of mysql_select_db?
3) instead of mysql_query?
Also, How can I verify that I've successfully connected?
I tried the following on a local flavor of MySQL just to get the correct code to connect/select:Code: Select all
<?php
/* database.php
This is a test PHP file
By Joe Johnson
*/
echo "Database - MySQL<br>";
$conn = mysql_connect("localhost", "test", "test");
mysql_select_db("test",$conn);
$sql = "SELECT * from JoesTable";
$result = mysql_query($sql, $conn) or die(mysql_error());
echo $result;
?>TIA,
jej1216
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]