skorp Posted December 3, 2006 Share Posted December 3, 2006 Hey guys,Small problem with a section of my code. I'm getting the error :[code]Parse error: parse error in c:\\\www\CLockTableCmd.php on line 4[/code]This is commonly caused by leaving out a ; or )But i cant see the problem ;)Heres the code,[code]<?php require_once( "DB.php" );require_once( "CCommand.php");require_once( "CUnlockTableCmd.php" );require_once( "settings.php" );function Execute( $sTableName ){ $db = DB::connect( $GLOBALS['g_PearDBDSN'] ); If (DB::isError( $db )) { $this->OnError("Failed to connect to the database using " . $GLOBALS['g_PearDBDSN'] . $db->getMessage()); return CMD_ERROR; } $result = $db->Query( "LOCK TABLES $sTableName WRITE" );(DB::isError( $result )) { $this->OnError("Failed to lock $sTableName"); return CMD_ERROR; }{ $this->m_bNeedRollBack = true; }return CMD_FINISHED; } function OnRollBack() { ( $this->m_bNeedRollBack == false ) { return; } $unlock = new CUnlockTableCmd( $null ); $unlock->Execute( ); }}?>[/code]Any help would be great thanks,skorp Link to comment https://forums.phpfreaks.com/topic/29279-small-problem/ Share on other sites More sharing options...
kenrbnsn Posted December 3, 2006 Share Posted December 3, 2006 I believe you want an "if" statement here:[code]<?phpif (DB::isError( $db )) // <--- if added{ $this->OnError("Failed to connect to the database using " . $GLOBALS['g_PearDBDSN'] . $db->getMessage()); return CMD_ERROR; }?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/29279-small-problem/#findComment-134202 Share on other sites More sharing options...
genericnumber1 Posted December 3, 2006 Share Posted December 3, 2006 and...php isn't a command php would understand :Pdo<?or<?phpdont do <? then put php on a different line Link to comment https://forums.phpfreaks.com/topic/29279-small-problem/#findComment-134203 Share on other sites More sharing options...
skorp Posted December 3, 2006 Author Share Posted December 3, 2006 No change ???*Yeah i had <?php ?>The code command spaced everything for some reason Link to comment https://forums.phpfreaks.com/topic/29279-small-problem/#findComment-134204 Share on other sites More sharing options...
genericnumber1 Posted December 3, 2006 Share Posted December 3, 2006 let me look some more then :DUPDATE: oh, you have a ; after your function...function Execute( $sTableName );{remove that ; :P Link to comment https://forums.phpfreaks.com/topic/29279-small-problem/#findComment-134207 Share on other sites More sharing options...
skorp Posted December 3, 2006 Author Share Posted December 3, 2006 [quote author=genericnumber1 link=topic=117169.msg477790#msg477790 date=1165123799]let me look some more then :D[/quote]Yeah ive added the If and removed the ;Still Fault on line 4 though_______________________________-function Execute( $sTableName ){ Edited now Link to comment https://forums.phpfreaks.com/topic/29279-small-problem/#findComment-134208 Share on other sites More sharing options...
genericnumber1 Posted December 3, 2006 Share Posted December 3, 2006 on a side note, you have tons of problems in there.. looks like you have some random brackets laying around, you're missing ifs, you had some stray semicolons initially, you're capitalizing some things you shouldn't be capitalizing "If" and some other things that just make no sense... you really need to go through that code and fix it up, I tried to fix it for you to post here, but there are just some if/then statements missing that I cant do. Link to comment https://forums.phpfreaks.com/topic/29279-small-problem/#findComment-134211 Share on other sites More sharing options...
skorp Posted December 3, 2006 Author Share Posted December 3, 2006 Ok nps bro,I understand that, i got the bigger picture on this end :)I'll keep at it and if i get any closer ill post back.Thanks anyway,skorp Link to comment https://forums.phpfreaks.com/topic/29279-small-problem/#findComment-134213 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.