Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database connectivity

Status
Not open for further replies.

jeffsurfs

MIS
Aug 9, 2001
19
US
I put the following code in a CGI shopping cart and am getting errors. Anyone have any ideas.

## includes
include("config.php");

## check login
## connect and execute query
$connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!");
$query = "SELECT * from $frmtable WHERE EID = '$Econ_BillTo_Office_EmployeeNumber'AND LName = '$Econ_ShipTo_Postal_Name_Last'";
$result = mysql_db_query($database, $query, $connection) or die ("Error in
query: $query. " . mysql_error());

## if row exists - login is correct
if (mysql_num_rows($result) == 1)
{
##display user details
$row = mysql_fetch_array($result);

$total_points = $row[3];
$points_used = $row[6];
$tpavail = $row[7];






<TABLE WIDTH=&quot;100%&quot; BORDER=&quot;1&quot; ALIGN=&quot;center&quot;>
<TR>
<TD WIDTH=&quot;18%&quot; ALIGN=&quot;center&quot;>Last Name</TD>
<TD WIDTH=&quot;17%&quot; ALIGN=&quot;center&quot;>First Name</TD>
<TD WIDTH=&quot;15%&quot; ALIGN=&quot;center&quot;>Total Points</TD>
<TD WIDTH=&quot;15%&quot; ALIGN=&quot;center&quot;>May</TD>
<TD WIDTH=&quot;15%&quot; ALIGN=&quot;center&quot;>June</TD>
<TD WIDTH=&quot;10%&quot; ALIGN=&quot;center&quot;>Points Used</TD>
<TD WIDTH=&quot;10%&quot; ALIGN=&quot;center&quot;>Total Points Available</TD>
</TR>
<TR>

print &quot;<TD>$row[1]</TD>&quot;;
print &quot;<TD>$row[2]</TD>&quot;;
print &quot;<TD>$row[3]</TD>&quot;;
print &quot;<TD>$row[4]</TD>&quot;;
print &quot;<TD>$row[5]</TD>&quot;;
print &quot;<TD>$row[6]</TD>&quot;;
print &quot;<TD>$row[7]</TD>&quot;;

mysql_free_result ($result);


## close connection
mysql_close($connection);



</TD></TR></TABLE>


else
## login/pass check failed
{
mysql_free_result ($result);
mysql_close($connection);
## redirect to error page
##header(&quot;Location: error.php?ec=0&quot;);

exit;
}




 
There is no include statement in perl. Instead, you need to use require. Here's an example:

require &quot;file.pl&quot;;

Second, I think you're mixing PHP. I also don't think there is mysql_num_rows statement in perl. ----------------------------------------
There is no Knowledge, That is not power.

Yes, i'm a MySQL Newbie.
-Aaron
----------------------------------------
 
Hehe, your in the wrong forum. Try this one.

forum434

Hope this helps.

-Vic vic cherubini
krs-one@cnunited.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top