Hello! Curious if anyone could give me a hand. I wrote this PHP
script with makes a simple connection to a mysql database called
firstdb and just pulls back the results and displays on the webpage.
Here is the script.
I appreciate any light that could be shed on the script and why I would
get the errors.
Thank you,
Mike
---------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Sample PHP Script</title>
</head>
<body style="font-family:Arial, Helvetica, sans-serif"
style="backgrou nd-color:#CC9966">
<?php
// Define connection string
$host = "localhost" ;
$user = "root";
$pass = "*******";
//open a persistant connection to the database
$connect = mysql_connect($ host, $user, $pass);
//Select the database
mysql_select_db ("myfirstdb" , $connect);
//Set and run the query
$sql = "Select Employee_no, Last_name, First_name, Commission from
Sales_Represent ative";
$result = mysql_query($sq l, $connect);
$x = mysql_num_rows( $result);
//If the tenth row exists, go straight to it
if ($x >= 10) {
mysql_data_seek ($result, 9);
}
//Return the data from the 10th row
$row = mysql_fetch_arr ay($result);
Print "Employee_n o: " . $row["Employee_N o"] . "<br>\n";
Print "Last_Name: " . $row["Last_Name"] . "<br>\n";
Print "First_Name : " . $row["First_Name "] . "<br>\n";
Print "Commission : " . $row["Commission "];
?>
</body>
</html>
script with makes a simple connection to a mysql database called
firstdb and just pulls back the results and displays on the webpage.
Here is the script.
I appreciate any light that could be shed on the script and why I would
get the errors.
Thank you,
Mike
---------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Sample PHP Script</title>
</head>
<body style="font-family:Arial, Helvetica, sans-serif"
style="backgrou nd-color:#CC9966">
<?php
// Define connection string
$host = "localhost" ;
$user = "root";
$pass = "*******";
//open a persistant connection to the database
$connect = mysql_connect($ host, $user, $pass);
//Select the database
mysql_select_db ("myfirstdb" , $connect);
//Set and run the query
$sql = "Select Employee_no, Last_name, First_name, Commission from
Sales_Represent ative";
$result = mysql_query($sq l, $connect);
$x = mysql_num_rows( $result);
//If the tenth row exists, go straight to it
if ($x >= 10) {
mysql_data_seek ($result, 9);
}
//Return the data from the 10th row
$row = mysql_fetch_arr ay($result);
Print "Employee_n o: " . $row["Employee_N o"] . "<br>\n";
Print "Last_Name: " . $row["Last_Name"] . "<br>\n";
Print "First_Name : " . $row["First_Name "] . "<br>\n";
Print "Commission : " . $row["Commission "];
?>
</body>
</html>
Comment