I am a newbie to PHP..
It would be great if someone would take a look at this code to see if I have all the sytax correct. All the : " $ () "" == $query () " stuff.
I am working on both extracting data from my database and inserting new data.
THANK YOU!
Here is the code:
include ("password.inc") ;
$link = mysql_connect( $hostname, $dbuser, $dbpassword )
or die("Could not connect to Database");
print "<b>Connected successfully </b><br>" ;
mysql_select_db("dare2feel_com")
or die("Could not select database");
$query = "select member_id , first_name , last_name , email , user_name, decode(password,'enc') , from member_corp_coach where type in ('P' , 'B') and user_name = '$user_name' and decode(password,'enc')='$password'" ;
$result = mysql_query ( $query) ;
$counter = 0 ;
if ($result == 0 ) {
print "<B>Error in first query</b>";
/* header("Location:http://www.dare2feel.com/members/eclasses1.php"); */
exit ;
}
$query1 = "SELECT course_id, course_desc, member_price FROM course" ;
$result = mysql_query($query1)
or die("Query failed");
// Printing results in HTML
print "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
print "\t<tr>\n";
foreach ($line as $col_value) {
print "\t\t<td>$col_value</td>\n";
}
print "\t</tr>\n";
}
print "</table>\n";
// Free resultset
mysql_free_result($result);
$query2 = "insert into course_member ( course_id , member_id , course_reg_date,
member_type , member_price ) values ( $course_id, $member_id, $member_type,
sysdate(), $member_price )" ;
$result2 = mysql_query ( $query2) ;
if ( $result == 0 )
print ( "There is a problem " ) ;
else
print ( mysql_affected_rows() . "added") ;