Can anyone tell me what's wrong with this script?
Hey everyone.I'm working on porting an ad management and exchange script from asp to php, but it is generating odd errors. Still new to the php world, and I am not entirely sure what I'm doing wrong. I'm not asking for new code, but if someone could tell me what I'm doing wrong, it would really help.
Thanks.
Here's the ported code:
<?
session_start();
session_register("unique_session");
session_register("autoid_session");
?>
<?
if ($unique_session=="")
{
// Create database connection string, login and password variables
$MySQLSVR="localhost"; // enter IP or hostname of MySQL server
;
$MySQLPRT=3306; // enter MySQL port (default 3306)
;
$MySQLUID="root"; // enter Username (between quotes)
;
$MySQLPWD=""; // enter Password (between quotes)
;
$MySQLDB="bx4"; // enter Active DataBase (between quotes)
;
$MySQLOPT=16387; // enter MyODBC options values (at least 16387)
;
// Loading up the the MySQL Database.
$strConn="driver={MySQL};server=".$MySQLSVR.";port=".$MySQLPRT.";"
."uid=".$MySQLUID.";pwd=".$MySQLPWD.";database=".$MySQLDB.";option=".$MySQLOPT."";
$mySqlads_STRING=$strConn; ?>
<?
//Establishing Contstants
$myown="1";
if (($HTTP_GET_VARS["autoid"]!=""))
{
$myown=$HTTP_GET_VARS["autoid"];
}
$mycategory=$HTTP_GET_VARS["tempid"];
if ($HTTP_GET_VARS["tempid"]=="")
{
$mycategory="14";
}
//Now, we find the ad
// $theaditself is of type "ADODB.Recordset"
echo $mySqlads_STRING;
echo "SELECT * FROM ads WHERE status=2 AND bank>0 AND
tempid=".$mycategory." AND autoid <> ".$myown."";
echo 1;
echo 2;
echo 3;
mysql_query($theaditself_CommandText,$theaditself_ActiveConnection);
$theaditself_numRows=0;
//Now we count the records in the recordset, and randomly pick one
where the select critiria works.
mt_srand((double)microtime()*1000000);
mysql_data_seek($theaditself_query,();
$Cint[mysql_num_rows($theaditself_query)]);
//Cleaning up the database calls
$autoid=(.$Item["autoid"].$Value);
$autoid_session=$autoid;
$bank=(.$Item["bank"].$Value);
$banner=(.$Item["formcode"].$Value);
$tempid=$mycategory;
$URL=(.$Item["url"].$Value);
$title=(.$Item["title"].$Value);
?>
<?
//Now here's where we have some fun. The code below will generate the
unchatable javascript that makes the banner.
if (!($theaditself==0) || !($theaditself_BOF==1))
{
?>
var ob = '0' var obx = '468' var obx2 = '60' var target = '_parent'
var image
= 'uploads/<? echo $banner; ?>.gif' var link =
'catapolt.asp?autoid=<? echo $autoid; ?>' document.write("<A
target=\""+target+"\" href=\""+link+"\">"); document.write("<Img
width=\""+obx+"\" height=\""+obx2+"\" border=\""+ob+"\"
src=\""+image+"\">");
document.write("<\/a>");
<?
//Think of the trading of links like a bank transaction.
//There are two parties involved, and credits need to trade hands.
//First we charge for service by debiting the ad shown on the page.
// $chargetheuser is of type "ADODB.Command"
$chargetheuser_ActiveConnection=$mySQLads_STRING;
$chargetheuser_CommandText="UPDATE ads SET impx=impx+1,
bank=bank-1 WHERE autoid=".$autoid." ";
//chargetheuser.CommandType = 1
//chargetheuser.CommandTimeout = 0
//chargetheuser.Prepared = true
$chargetheuser_Execute=);
//So now that the money has been taken out of one account, it needs to
be put into another.
//In this instance the user earns three credits for every unique
banner shown.
//Here's how you do it.
// $= is of type "ADODB.Command"
$chargetheuser.$ActiveConnection=$mySQLads_STRING;
$chargetheuser.$CommandText="UPDATE ads SET bank=bank+3,
onmypage=onmypage+1 WHERE autoid=".$myown." ";
$chargetheuser.$CommandType=1;
$chargetheuser.$CommandTimeout=0;
$chargetheuser.$Prepared=true;
$chargetheuser.$Execute[];
$unique_session="used";
}
}
?>