Damn php syntax problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Hammer136
Forum Commoner
Posts: 29
Joined: Sat Mar 19, 2005 12:18 pm

Damn php syntax problems

Post 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
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

what error is it giving you?
Hammer136
Forum Commoner
Posts: 29
Joined: Sat Mar 19, 2005 12:18 pm

Post by Hammer136 »

Parse error: syntax error, unexpected T_STRING in C:\Documents and Settings\KCHardy\Local Settings\Temp\dzp83.tmp on line 13
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Code: Select all

Set $objmaindb = $objcon.Execute($SQLstr);
That looks like ASP to me. Whatever it is, it ain't PHP.
Hammer136
Forum Commoner
Posts: 29
Joined: Sat Mar 19, 2005 12:18 pm

Post by Hammer136 »

it is asp i think! but how do i get around this?
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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
Hammer136
Forum Commoner
Posts: 29
Joined: Sat Mar 19, 2005 12:18 pm

Post 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
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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(" ",
Post Reply