I'm very new to PHP, SQL I've worked with using Coldfusion but only with very simple queries. In coldfusion to access a specific database
<cfquery dbname="blah">
I know in PHP I have to use mysql_query() and mysql_connect(), and here is the code I have, so I understand how to access a server and a table, but not the database. How can this be done?
<?php
$sql_branch = "SELECT BranchNum
FROM Branch WHERE
branchName = '$_POST[branch]'";
$connect = mysql_connect('students','xxxxxxx','xxxxxxx');
if(mysql_query($sql_branch, $connect)) {
$branch = mysql_query($sql_branch, $connect);
}
else {
echo "error".mysql_error();
}
$sql_result = "USE henrybooks;
SELECT AuthorFirst, AuthorLast, OnHand, Title
FROM Inventory i, Wrote w, Author a, Book b
WHERE i.BookCode = b.BookCode AND
i.BookCode = w.BookCode AND a.AuthorNum =
w.AuthorNum AND i.BranchNum = $branch";
if(mysql_query($sql_result, $connect)) {
$result = mysql_query($sql_result, $connect);
}
else {
echo "Error".mysql_error();
}
Also I'm unsure if my Error checking is right, my professor did not really explain how that works exactly.
Thanks!