Hi everybody,
I ran my script, but to my dismay it returned to me the following error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/1/addinvoice.php on line 13
I am not sure of the cause, but after googling I stumbled upon this site and am asking for help.
Here is my code:
<?
include("quickform.php");
require_once("connect_db.php");
$date=date(Y/m/d');
$ddate= mktime(0, 0, 0, date("m")+1, date("d"), date("Y"));
$companies="";
$q1=mysql_query("SELECT * FROM companies");
$numcomp=mysql_num_rows($q1);
for($i=0; $i<$numcomp; $i++)
{
$q="SELECT * FROM companies where c_id = '$cid';";
$r=mysql_query($q);
if (!$result) {
die("UH-OH, something crashed..... <br />Query is: $q <br />Error is: ".mysql_error());
}
$loop=mysql_fetch_row($result);
$companies.=$loop[1];
$companies.=",";
}
echo "<br>".$companies."<br>";
$mainarray = array(
array("Invoice ID", "", "text"),
array("Company", "", "menu"),
array("Invoice Date","$date","text");
array("Invoice Due Date","$ddate","text");
array("Amount Due","","text");
array("Amount Paid","","text");
array("Invoice Description", "", "textarea"));
quickform("Add Invoice",$mainarray);
//START DOING MYSQL QUERIES
$query="INSERT into companies (c_id, c_name, c_address, c_phone, c_fax, c_contact, c_contact_phone, c_contract_email, c_website, c_tax_id)
VALUES ('','$_POST[0]', '$_POST[1]', '$_POST[2]', '$_POST[3]', '$_POST[4]', '$_POST[5]', '$_POST[6]', '$_POST[7]', '$_POST[8]');";
$query2=mysql_query("SELECT * FROM companies WHERE c_name = '$_POST[0]';");
$count=mysql_num_rows($query2);
if($count>1){
printf("<font color=red>Duplicate company found.</font>");
}
$result=mysql_query($query);
echo $count;
if($count ){
printf("<font color=green>Company successfully added</font>");
}
else {
echo "<font color=red>Wrong Username or Password</font>";
}
?>
Thanks so much for checking my code and it would be fantastic if you could highlight my problem.
Thanks,
Soule