Page 1 of 1

Damn php syntax problems

Posted: Thu May 19, 2005 8:40 am
by Hammer136
If you have read my other posts i am young and a novice to php. So please forgive me if the errors are really obvious to you. Please look at this and help me:

Code: Select all

<?php


 include "incdmh.php";



 include "incdh.php";

	echo $header;

	$SQLstr = "SELECT Plants, Land, StPlants FROM MainValues WHERE ID = ".$pid.";";
	Set $objmaindb = $objcon.Execute($SQLstr);

	$tarray = explode( ",$objmaindb["Plants"]);
	$tiarray = explode( ",$objmaindb["Land"]);
	$ticarray = explode( ",$objmaindb["StPlants"]);
	if ((120 * $tiarray[0]) - $tarray[0] < 0 || (360 * $tiarray[1]) - $tarray[1] < 0 || (2500 * $tiarray[2]) - $tarray[2] < 0 || (2000 * $tiarray[3]) - $tarray[3] < 0) {
		$yesorno = "Yes";
	}
	if ((120 * $tiarray[0]) - $tarray[0] < 0) {
		$ticarray[0] = floor($ticarray[0]) + ($tarray[0] - (120 * $tiarray[0]));
		$tarray[0] = 120 * $tiarray[0];
	}
	if ((360 * $tiarray[1]) - $tarray[1] < 0) {
		$ticarray[1] = floor($ticarray[1]) + ($tarray[1] - (360 * $tiarray[1]));
		$tarray[1] = 360 * $tiarray[1];
	}
	if ((2500 * $tiarray[2]) - $tarray[2] < 0) {
		$ticarray[2] = floor($ticarray[2]) + ($tarray[2] - (2500 * $tiarray[2]));
		$tarray[2] = 2500 * $tiarray[2];
	}
	if ((2000 * $tiarray[3]) - $tarray[3] < 0) {
		$ticarray[3] = floor($ticarray[3]) + ($tarray[3] - (2000 * $tiarray[3]));
		$tarray[3] = 2000 * $tiarray[3];
	}
	if ($yesorno == "Yes") {
		$SQLstr = "UPDATE MainValues SET Plants = '".$tarray[0].",".$tarray[1].",".$tarray[2].",".$tarray[3]."', StPlants = '".$ticarray[0].",".$ticarray[1].",".$ticarray[2].",".$ticarray[3]."' WHERE ID = ".$pid.";";
		$objcon.Execute($SQLstr);
	}

	echo "Like Magic..";

?>
<? include "incdf.asp"; ?>undefined
Oh and sorry ive posted all of it but i expect there are multiple errors in it as i made it!!!!!

Thanx

Posted: Thu May 19, 2005 8:52 am
by Wayne
what error is it giving you?

Posted: Thu May 19, 2005 8:53 am
by Hammer136
Parse error: syntax error, unexpected T_STRING in C:\Documents and Settings\KCHardy\Local Settings\Temp\dzp83.tmp on line 13

Posted: Thu May 19, 2005 9:02 am
by onion2k

Code: Select all

Set $objmaindb = $objcon.Execute($SQLstr);
That looks like ASP to me. Whatever it is, it ain't PHP.

Posted: Thu May 19, 2005 9:03 am
by Hammer136
it is asp i think! but how do i get around this?

Posted: Thu May 19, 2005 9:10 am
by phpScott

Code: Select all

$result = mysql_query ($SQLstr) or die (mysql_error());
you should check out the mysql_* functions on php.net
as that will help you get through a lot of your query problems.

assuming you are using mysql other wise there are heaps of built in functions for most db's

Posted: Thu May 19, 2005 9:17 am
by Hammer136
Thanx but now i have error:

Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Documents and Settings\KCHardy\Local Settings\Temp\dzp9B.tmp on line 16

Thanx

Posted: Thu May 19, 2005 10:10 am
by phpScott

Posted: Thu May 19, 2005 10:12 am
by n00b Saibot
These lines want notice

Code: Select all

$tarray = explode( ",$objmaindb["Plants"]);
$tiarray = explode( ",$objmaindb["Land"]);
$ticarray = explode( ",$objmaindb["StPlants"]);
simply change all explode( ", to explode(" ",