PHP - An Error Occurred In Script '/home/wwwview/public_html/niftyuk-new-site/theme/ad
fIXED
Similar Tutorialshello, if any one can help me solve this error.
case "unsuspend": $setupd = array("status" => "Active"); $db->update("members", $setupd, "id=" . $mid); break; case "activate": $setupd = array("status" => "Active"); $db->update("members", $setupd, "id=" . $mid); { if ($settings['referral_contest'] == 'yes') { $usr = $db->fetchRow( "SELECT ref1, status FROM members WHERE id=" . $mid ); if (( $usr['status'] == 'Un-verified' && $usr['ref1'] != 0 )) { $referrer = $usr['ref1']; if ($referrer != 0) { $today_var = $settings['referral_reset']; $chk = $db->fetchOne( "SELECT COUNT(*) AS NUM FROM referral_stats WHERE user_id=" . $referrer ); if ($chk == 0) { $data = array( 'user_id' => $referrer, 'day' . $today_var => 1 ); $db->insert( 'referral_stats', $data ); } else { $db->query( "UPDATE referral_stats SET day" . $today_var . '=day' . $today_var . '+1 WHERE user_id=' . $referrer ); } } } } break; case "delete": $userdata = $db->fetchRow("SELECT username, country, ref1 FROM members WHERE id=" . $mid); deletemember($mid); if ($userdata['username'] != "BOT") { $db->query("UPDATE country SET users=users-1 WHERE name=" . $userdata['country'] . "'"); } if ($userdata['ref1'] != 0) { $db->query("UPDATE members SET referrals=referrals-1, myrefs1=myrefs1-1 WHERE id=" . $userdata['ref1']); } break; Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/myritebook/public_html/footer.php on line 13 I am trying to fix the above error. Please Help. code is given below:
<?php
if ($conn) {
try{
catch(Exception $e){ Hi! So I'm working for someone, and they want me to fix this error in a PHP file.. Here is the code: <?php include_once('config.php'); $online = mysql_query("SELECT * FROM bots WHERE status LIKE 'Online'"); $offline = mysql_query("SELECT * FROM bots WHERE status LIKE 'Offline'"); $dead = mysql_query("SELECT * FROM bots WHERE status LIKE 'Dead'"); $admintrue = mysql_query("SELECT * FROM bots WHERE admin LIKE 'True'"); $adminfalse = mysql_query("SELECT * FROM bots WHERE admin LIKE 'False'"); $windows8 = mysql_query("SELECT * FROM bots WHERE so LIKE '%8%'"); $windows7 = mysql_query("SELECT * FROM bots WHERE so LIKE '%7%'"); $windowsvista = mysql_query("SELECT * FROM bots WHERE so LIKE '%vista%'"); $windowsxp = mysql_query("SELECT * FROM bots WHERE so LIKE '%xp%'"); $unknown = mysql_query("SELECT * FROM bots WHERE so LIKE 'Unknown'"); $totalbots = mysql_num_rows(mysql_query("SELECT * FROM bots")); $onlinecount = 0; $offlinecount = 0; $deadcount = 0; $admintruecount = 0; $adminfalsecount = 0; $windows8count = 0; $windows7count = 0; $windowsvistacount = 0; $windowsxpcount = 0; $unknowncount = 0; while($row = mysql_fetch_array($online)){ $onlinecount++; } while($row = mysql_fetch_array($offline)){ $offlinecount++; } while($row = mysql_fetch_array($dead)){ $deadcount++; } while($row = mysql_fetch_array($admintrue)){ $admintruecount++; } while($row = mysql_fetch_array($adminfalse)){ $adminfalsecount++; } while($row = mysql_fetch_array($windows8)){ $windows8count++; } while($row = mysql_fetch_array($windows7)){ $windows7count++; } while($row = mysql_fetch_array($windowsvista)){ $windowsvistacount++; } while($row = mysql_fetch_array($windowsxp)){ $windowsxpcount++; } while($row = mysql_fetch_array($unknown)){ $unknowncount++; } $statustotal = $onlinecount + $offlinecount + $deadcount; $admintotal = $admintruecount + $adminfalsecount; $sototal = $windows7count + $windowsvistacount + $windowsxpcount + $unknowncount; ?> Can anyone tell me the error here, can how to fix it? Hey Everyone, I'm getting this error when I submit my contact form. Parse error: syntax error, unexpected $end in /home1/user/public_html/contact/process.php on line 22 I got this code from a video on youtube. http://www.youtube.com/watch?v=rdsz9Ie6h7I If I made a mistake or TYPO please let me know. Thanks! Here's my code: <?php $emailSubject = 'Contact Form Submission'; $sendto = 'info@mydomain.com'; $nameField = $_Post['name']; $emilField = $_Post['email']; $phoneField = $_Post['phone']; $SubjectField = $_Post['subject']; $messageField = $_Post['message']; $body = <<<EOD <br><hl><br>This Form was submitted from the Domain.com contact page.<br> Name: $name<br> E-Mail: $email<br> Phone: $phone<br> Subject: $subject<br> Message: $message<br> BOD; $headers = "FROM: $email\r\n"; $headers .="Content-Type: text/html\r\n"; $success = mail($sendto, $emailSubject, $body, $headers); ?> I have been getting that error and I cannot figure out why it is happening Here is the error: Parse error: syntax error, unexpected T_ENDWHILE, expecting ',' or ';' in /home/scswc188/public_html/index.php on line 23 Here is my Code (Database Credentials removed for obvious reasons) <?PHP // Conect to the Mysql Server $connect = mysql_connect("IP","USER","PASS"); //connect to the database mysql_select_db("TABLE"); //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 1"); // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "'<font color='black'>Online:<font color='green'>$users, </font></font>;" endwhile; ?> or here http://pastebin.com/ZYh4t2pD Thanks Edit: Found the php tag the code is <?php $qty=$_POST['quantity']; $service=$_POST['service']; $reciept=$_POST['reciept']; if (service=SC1) {$desc="Hourly Service"; $price = "20";} elseif (service=SC2) {$desc="Hourly Service - Half hour"; $price = "10";} elseif (service=SC3) {$desc="Hourly Service - Extended area"; $price = "30";} elseif (service=SC5) {$desc="Virus Removal / Computer Cleanup"; $price = "40";} elseif (service=cl1) {$desc="Physical Cleaning of computer"; $price = "10";} elseif (service=ba1) {$desc="Data backup \$1 per 5gb"; $price = "1";} elseif (service=OS1) {$desc="Windows XP install"; $price = "50";} elseif (service=OS2) {$desc="Windows Vista install"; $price = "50";} elseif (service=OS3) {$desc="Windows 7 install"; $price = "50";} elseif (service=OS4) {$desc="Windows XP install - No disk"; $price = "50";} elseif (service=OS5) {$desc="Windows Vista install - No disk"; $price = "120";} elseif (service=OS6) {$desc="Windows 7 install - No disk"; $price = "250";} elseif (service=OS6) {$desc="Linux install"; $price = "50";} elseif (service=OS6) {$desc="Linux install - No disk"; $price = "60";} $total = $price * $qty; mysql_select_db($database_local, $local); { $sql=mysql_query("INSERT INTO service (qty, item, description, price, discount, total, reciept) VALUES('$qty','$service','$desc', '$price', '$discount', '$total', '$reciept') ") or die(mysql_error()); $result=mysql_query($sql); } I've looked it over myself and run a syntax checker, neither can find an error Hi Im using a php theme script and I want to use jcart with this script. The thing is my theme scrip dosen't use echo. When I need to display something I have to use something like this $_PAGE = "<div id='jcart'>..." and if i use echo i recieve header error. i changed couple of thing and now i cant see cart but when i click add to cart button it says Item added but all cart is disappearing. you can see here could you help me please thanks. Code: [Select] <THEME Name={ShopNavDivEnd}> </ul> </div> <br /><br /><br /><br /> <VAR>_JCART</VAR> </div> </THEME> this is shop.php Code: [Select] $_JCART .= "<div id='jcart'>".$jcart->display_cart()."</div>"; i changed the jcart.php class to like this. I mean all echo to $_PAGE .= "..." Code: [Select] // Return specified number of tabs to improve readability of HTML output function tab($n) { $tabs = null; while ($n > 0) { $tabs .= "\t"; --$n; } return $tabs; } // If there's an error message wrap it in some HTML if ($errorMessage) { $errorMessage = "<p id='jcart-error'>$errorMessage</p>"; } // Display the cart header $_JCART .= tab(1) . "$errorMessage\n"; $_JCART .= tab(1) . "<form method='post' action='$checkout'>\n"; $_JCART .= tab(2) . "<fieldset>\n"; $_JCART .= tab(3) . "<input type='hidden' name='jcartToken' value='{$_SESSION['jcartToken']}' />\n"; $_JCART .= tab(3) . "<table border='1'>\n"; $_JCART .= tab(4) . "<thead>\n"; $_JCART .= tab(5) . "<tr>\n"; $_JCART .= tab(6) . "<th colspan='3'>\n"; $_JCART .= tab(7) . "<strong id='jcart-title'>{$config['text']['cartTitle']}</strong> ($this->itemCount $itemsText)\n"; $_JCART .= tab(6) . "</th>\n"; $_JCART .= tab(5) . "</tr>". "\n"; $_JCART .= tab(4) . "</thead>\n"; // Display the cart footer $_JCART .= tab(4) . "<tfoot>\n"; $_JCART .= tab(5) . "<tr>\n"; $_JCART .= tab(6) . "<th colspan='3'>\n"; // If this is the checkout hide the cart checkout button if ($isCheckout !== true) { if ($config['button']['checkout']) { $inputType = "image"; $src = " src='{$config['button']['checkout']}' alt='{$config['text']['checkout']}' title='' "; } $_JCART .= tab(7) . "<input type='$inputType' $src id='jcart-checkout' name='jcartCheckout' class='jcart-button' value='{$config['text']['checkout']}' />\n"; } $_JCART .= tab(7) . "<span id='jcart-subtotal'>{$config['text']['subtotal']}: <strong>$currencySymbol" . number_format($this->subtotal, $priceFormat['decimals'], $priceFormat['dec_point'], $priceFormat['thousands_sep']) . "</strong></span>\n"; $_JCART .= tab(6) . "</th>\n"; $_JCART .= tab(5) . "</tr>\n"; $_JCART .= tab(4) . "</tfoot>\n"; $_JCART .= tab(4) . "<tbody>\n"; // If any items in the cart if($this->itemCount > 0) { // Display line items foreach($this->get_contents() as $item) { $_JCART .= tab(5) . "<tr>\n"; $_JCART .= tab(6) . "<td class='jcart-item-qty'>\n"; $_JCART .= tab(7) . "<input name='jcartItemId[]' type='hidden' value='{$item['id']}' />\n"; $_JCART .= tab(7) . "<input id='jcartItemQty-{$item['id']}' name='jcartItemQty[]' size='2' type='text' value='{$item['qty']}' />\n"; $_JCART .= tab(6) . "</td>\n"; $_JCART .= tab(6) . "<td class='jcart-item-name'>\n"; if ($item['url']) { $_PAGE .= tab(7) . "<a href='{$item['url']}'>{$item['name']}</a>\n"; } else { $_PAGE .= tab(7) . $item['name'] . "\n"; } $_JCART .= tab(7) . "<input name='jcartItemName[]' type='hidden' value='{$item['name']}' />\n"; $_JCART .= tab(6) . "</td>\n"; $_JCART .= tab(6) . "<td class='jcart-item-price'>\n"; $_JCART .= tab(7) . "<span>$currencySymbol" . number_format($item['subtotal'], $priceFormat['decimals'], $priceFormat['dec_point'], $priceFormat['thousands_sep']) . "</span><input name='jcartItemPrice[]' type='hidden' value='{$item['price']}' />\n"; $_JCART .= tab(7) . "<a class='jcart-remove' href='?jcartRemove={$item['id']}'>{$config['text']['removeLink']}</a>\n"; $_JCART .= tab(6) . "</td>\n"; $_JCART .= tab(5) . "</tr>\n"; } } // The cart is empty else { $_PAGE = tab(5) . "<tr><td id='jcart-empty' colspan='3'>{$config['text']['emptyMessage']}</td></tr>\n"; } $_JCART .= tab(4) . "</tbody>\n"; $_JCART .= tab(3) . "</table>\n\n"; $_JCART .= tab(3) . "<div id='jcart-buttons'>\n"; if ($config['button']['update']) { $inputType = "image"; $src = " src='{$config['button']['update']}' alt='{$config['text']['update']}' title='' "; } $_JCART .= tab(4) . "<input type='$inputType' $src name='jcartUpdateCart' value='{$config['text']['update']}' class='jcart-button' />\n"; if ($config['button']['empty']) { $inputType = "image"; $src = " src='{$config['button']['empty']}' alt='{$config['text']['emptyButton']}' title='' "; } $_JCART .= tab(4) . "<input type='$inputType' $src name='jcartEmpty' value='{$config['text']['emptyButton']}' class='jcart-button' />\n"; $_JCART .= tab(3) . "</div>\n"; // If this is the checkout display the PayPal checkout button if ($isCheckout === true) { // Hidden input allows us to determine if we're on the checkout page // We normally check against request uri but ajax update sets value to relay.php $_JCART .= tab(3) . "<input type='hidden' id='jcart-is-checkout' name='jcartIsCheckout' value='true' />\n"; // PayPal checkout button if ($config['button']['checkout']) { $inputType = "image"; $src = " src='{$config['button']['checkout']}' alt='{$config['text']['checkoutPaypal']}' title='' "; } if($this->itemCount <= 0) { $disablePaypalCheckout = " disabled='disabled'"; } $_JCART .= tab(3) . "<input type='$inputType' $src id='jcart-paypal-checkout' name='jcartPaypalCheckout' value='{$config['text']['checkoutPaypal']}' $disablePaypalCheckout />\n"; } $_JCART .= tab(2) . "</fieldset>\n"; $_JCART .= tab(1) . "</form>\n\n"; $_JCART .= tab(1) . "<div id='jcart-tooltip'></div>\n"; return $_JCART; } } and this is my theme script Code: [Select] <?php class Theme { var $META = array(); var $JS = array(); var $BodyOn = array(); var $CSS = array(); var $TITLE = ""; var $Charset = "UTF-8"; var $Headers = ''; var $Body = array(); var $Vars = array(); var $ThemeList = array(); var $ThemeDir = ''; var $CacheDir = ''; var $ThemeName = ''; var $FirstTAG = ''; var $FirstPosition = 999999; var $ClassUpdated = 0; var $CompressOutput = true; var $MatchTAG = array( // Find And Replace 'FE' => array( 'Find' => '<FE Array={([^}]+)}>', 'Replace' => "if ( count( \$\\1 ) )\r\n<!TabCount!>{\r\n<!TabCount!>\tforeach ( \$\\1 as \$_KEY => \$_VALUE )\r\n<!TabCount!>\t{\r\n" ), '/FE' => array( 'Find' => '<\/FE>', 'Replace' => "\t}\r\n<!TabCount!>}\r\n" ), 'FF' => array( 'Find' => '<FF Array={([^}]+)}>', 'Replace' => "if ( count( \$\\1 ) )\r\n<!TabCount!>{\r\n<!TabCount!>\tforeach ( \$\\1 as \$_KFY => \$_VALUF )\r\n<!TabCount!>\t{\r\n" ), '/FF' => array( 'Find' => '<\/FF>', 'Replace' => "\t}\r\n<!TabCount!>}\r\n" ), 'IF' => array( 'Find' => '<IF State={([^}]+)}>', 'Replace' => "if ( \\1 )\r\n<!TabCount!>{\r\n" ), '/IF' => array( 'Find' => '<\/IF>', 'Replace' => "}\r\n" ), 'ELIF' => array( 'Find' => '<ELIF State={([^}]+)}>', 'Replace' => "else if ( \\1 )\r\n<!TabCount!>{\r\n" ), '/ELIF' => array( 'Find' => '<\/ELIF>', 'Replace' => "}\r\n" ), 'ELSE' => array( 'Find' => '<ELSE>', 'Replace' => "else\r\n<!TabCount!>{\r\n" ), '/ELSE' => array( 'Find' => '<\/ELSE>', 'Replace' => "}\r\n" ), 'VAR' => array( 'Find' => '<VAR>([^<]+)<\/VAR>', 'Replace' => "\$\\1" ), 'BIT' => array( 'Find' => '<BIT>([a-z0-9_]+)(\(([^<]*)\)|)<\/BIT>', 'Replace' => "t_\\1(\\3)" ), 'DEF' => array( 'Find' => '<DEF>([^<]+)<\/DEF>', 'Replace' => "\\1" ), 'PHP' => array( 'Find' => '<PHP>([^<]+);?<\/PHP>', 'Replace' => "\\1" ), 'THEME' => array( 'Find' => '<THEME Name={([^}]+)}\s*?(Vars?={([^}]+)})?>(.+)<\/THEME>' ), ); var $PredefinedGlobals = array( '_HTML', '_KEY', '_KFY', '_VALUE', '_VALUF', '_GET', '_POST', '_SESSION', '_COOKIE' ); /* * Base Functions * * <FE Array={Dizi}> ... </FE> * <IF State={$a == '4'}> ... </IF> * <ELIF State={$a == '4'}> ... </ELIF> * <ELSE> ... </ELSE> * <VAR> ... </VAR> * <BIT> ... </BIT> * * @param String $ThemeName * @return void */ function Theme() { global $CFG; $this->Charset = $CFG['Theme']['Charset']; $this->META = $CFG['Theme']['Meta']; $this->TITLE = $CFG['Title']; $this->ClassUpdated = filemtime( CLS_DIR . "theme.class.php" ); } /** * * @access public * @return void */ function setTHEME( $ThemeName ) { if ( !is_dir( THM_DIR . $ThemeName ) ) return false; $this->ThemeName = $ThemeName; $this->ThemeDir = THM_DIR . $ThemeName . '/Html/'; $this->CacheDir = CCH_DIR . 'Themes/' . $ThemeName . '/'; $this->initTHEME(); } /** * * @access public * @return void */ function initTHEME() { define( 'IMG_DIR', "http://" . SITE . "/Themes/" . $this->ThemeName . "/Image/" ); $this->loadTheme( "index" ); } function loadTheme( $FileName ) { $FileName = ucfirst( strtolower( $FileName ) ); // Theme HTML Exists ? if ( !file_exists( $this->ThemeDir . $FileName . ".tpl" ) ) { global $CFG; if ( $this->ThemeName != $CFG['Theme']['DefaultTheme'] ) { $_SESSION['ThemeName'] = $CFG['Theme']['DefaultTheme']; header( "Location: ?" ); die( 'falan filan' ); } else die( "Theme File Not Found: " . $FileName . ".tpl" ); } $this->ThemeList = array(); // Theme Cache Exists ? And Newer than the Theme HTML ? if ( file_exists( $this->CacheDir . $FileName . ".tpl.php" ) AND ( filemtime( $this->CacheDir . $FileName . ".tpl.php" ) > max( $this->ClassUpdated, filemtime( $this->ThemeDir . $FileName . ".tpl" ) ) ) ) $this->createFunctions( $FileName ); else $this->cacheTheme( $FileName ); } /** * * @access public * @return void */ function loadCSS( $CssFile ) { if ( eregi( 'http', $CssFile ) ) $this->CSS[] = $CssFile; else { global $_RWBASE; $FileName = THM_DIR . $this->ThemeName . '/Style/' . $CssFile; if ( file_exists( $FileName ) AND is_readable( $FileName ) ) $this->CSS[$CssFile] = $_RWBASE . $FileName; } } /** * * @access public * @return void */ function loadJS( $JsFile, $Code = false ) { if ( !$Code ) { if ( eregi( 'http', $JsFile ) ) $this->JS[] = '<script type="text/javascript" src="' . $JsFile . '"></script>'; else { global $_RWBASE; $FileName = BASE_DIR . 'Sources/JavaScript/' . $JsFile; if ( file_exists( $FileName ) AND is_readable( $FileName ) ) $this->JS[$JsFile] = '<script type="text/javascript" src="' . $_RWBASE . $FileName . '"></script>'; } } else $this->JS[$Code] = '<script type="text/javascript">' . $JsFile . '</script>'; } function addJS( $JsFile, $Code = false ) { $this->loadJS( $JsFile, $Code ); } /** * * @access public * @return void */ function bodyOn( $Type, $Code ) { $this->BodyOn[strtolower( $Type )][] = $Code; } /** * * @access public * @return void */ function writePage( $FinalFunction = "t_Page" ) { foreach ( $this->BodyOn as $key => $value ) { $this->loadJS( 'function bodyOn' . $key . '() {' . implode( $value ) . '}; onAttacher("' . $key . '",bodyOn' . $key . ');', 'on' . $key ); } $header = array( "<title>" . $this->TITLE . "</title>" ); foreach ( $this->META as $value ) $header[] = $value; foreach ( $this->JS as $value ) $header[] = $value; foreach ( $this->CSS as $value ) $header[] = '<style type="text/css" media="all">@import url(' . $value . ');</style>'; $this->Headers = implode( $header ); header( 'Content-Type: text/html; charset=' . $this->Charset ); echo $FinalFunction(); } function createFunctions( $FileName = '' ) { include_once( $this->CacheDir . $FileName . ".tpl.php" ); } function cacheTheme( $FileName ) { $FileContent = rFile( $this->ThemeDir . $FileName . ".tpl" ); if ( $this->CompressOutput ) $FileContent = $this->compressHTML( $FileContent ); $this->parseThemes( $FileContent ); wFile( $this->CacheDir . $FileName . ".tpl.php", "<" . "? \r\n" . $this->createThemeFunctions() . "\r\n?" . ">", 0777 ); $this->createFunctions( $FileName ); } function compressHTML( $Content ) { $Content = preg_replace( "/[\s]{2,}/", " ", $Content ); $Content = preg_replace( "/> </", "><", $Content ); return $Content; } function parseThemes( $Content ) { $Results = $this->findExactTAGs( $Content, "THEME" ); foreach ( $Results as $Value ) { preg_match( "/^" . $this->MatchTAG['THEME']['Find'] . "$/is", trim( $Value ), $Match ); $Vars = array(); if ( trim( $Match[3] ) != '' ) { $tVars = explode( ',', $Match[3] ); foreach ( $tVars as $vValue ) { if ( preg_match( '/^\$?([a-z0-9_]+)=?(.*)$/i', trim( $vValue ), $vMatch ) ) $Vars[$vMatch[1]] = "$" . $vMatch[1] . ( trim( $vMatch[2] ) != "" ? "=" . $vMatch[2] : "" ); } } $this->ThemeList[$Match[1]] = array( 'Code' => $Match[4], 'Vars' => $Vars ); } return true; } function findExactTAGs( $Content, $TAGName ) { $Results = array(); $CurrPos = 0; $Found = false; $Level = 0; // --------------------- $StartTAG = "<" . $TAGName; $EndTAG = "</" . $TAGName . ">"; $Repeat = substr_count( $Content, $StartTAG ); if ( substr_count( $Content, $EndTAG ) != $Repeat ) die( "Template ERROR: <$TAGName> sayısı ile </$TAGName> sayısı eşit değil!" ); // ----------------------------------- for( $i = 0; $i < $Repeat; $i++ ) { $Found = false; $Level = 0; $ContentStart = strpos( $Content, $StartTAG, $CurrPos ); $CurrPos = $ContentStart + strlen( $StartTAG ); while ( $Found == false ) { if ( $Level == 0 ) { $PosS = strpos( $Content, $StartTAG, $CurrPos ); $PosE = strpos( $Content, $EndTAG, $CurrPos ); if ( $PosS < $PosE AND $PosS !== false ) $Level++; else $Found = true; if ( $Found ) $ContentEnd = $PosE; $CurrPos = min( ( $PosS === false ? 999999 : $PosS ), ( $PosE === false ? 999999 : $PosE ) ) + 1; } else if ( $Level > 0 ) { $PosS = strpos( $Content, $StartTAG, $CurrPos ); $PosE = strpos( $Content, $EndTAG, $CurrPos ); if ( $PosS < $PosE AND $PosS !== false ) $Level++; else $Level--; $CurrPos = min( ( $PosS === false ? 999999 : $PosS ), ( $PosE === false ? 999999 : $PosE ) ) + 1; } } $Results[] = trim( substr( $Content, $ContentStart, $ContentEnd - $ContentStart + strlen( $EndTAG ) ) ); } // for return $Results; } function createThemeFunctions() { $FunctionList = array(); foreach ( $this->ThemeList as $Name => $ThemeData ) { $FunctionVars = $ThemeData['Vars']; $Content = $ThemeData['Code']; $FunctionCode = ''; $FunctionGlobals = array(); $this->TabCount = 1; $HtmlOpen = true; while ( ( $StartPoint = $this->getFirstTAG( $Content ) ) !== false ) { if ( $StartPoint == 0 ) { if ( !preg_match( '/^' . $this->MatchTAG[$this->FirstTAG]['Find'] . '/i', $Content, $Match ) ) die( 'Template Tag Error: ' . $this->FirstTAG ); if ( $this->FirstTAG == "THEME" ) { $SubThemes = $this->findExactTAGs( $Match[0], "THEME" ); foreach ( $SubThemes as $SubValue ) { preg_match( "/^" . $this->MatchTAG['THEME']['Find'] . "$/i", $SubValue, $SubMatch ); $SubVars = array(); if ( trim( $SubMatch[3] ) != '' ) { $tVars = explode( ',', $SubMatch[3] ); foreach ( $tVars as $vValue ) { if ( preg_match( '/^\$?([a-z0-9_]+)=?(.*)$/i', trim( $vValue ), $vMatch ) ) $SubVars[$vMatch[1]] = "$" . $vMatch[1] . ( trim( $vMatch[2] ) != "" ? "=" . $vMatch[2] : "" ); } } $this->ThemeList[$SubMatch[1]] = array( 'Code' => $SubMatch[4], 'Vars' => $SubVars ); $Content = str_replace( $SubMatch[0], '<BIT>' . $SubMatch[1] . ( count( $SubVars ) ? "(" . implode( ',', $SubVars ) . ")" : "" ) . '</BIT>', $Content ); } } else { if ( in_array( $this->FirstTAG, array( '/FE', '/FF', '/IF', '/ELIF', '/ELSE' ) ) ) $this->TabCount--; if ( in_array( $this->FirstTAG, array( '/FE', '/FF' ) ) ) $this->TabCount--; $Content = substr( $Content, strlen( $Match[0] ), strlen( $Content ) - strlen( $Match[0] ) ); if ( in_array( $this->FirstTAG, array( 'VAR', 'BIT', 'DEF', 'PHP' ) ) ) { if ( $HtmlOpen ) $FunctionCode .= " . "; else $FunctionCode .= $this->addTab() . "\$_HTML .= "; $HtmlOpen = true; } else { if ( $HtmlOpen ) $FunctionCode .= ";\r\n"; $FunctionCode .= $this->addTab(); $HtmlOpen = false; } $FunctionCode .= preg_replace( '/^' . $this->MatchTAG[$this->FirstTAG]['Find'] . '$/i', str_replace( '<!TabCount!>', $this->addTab(), $this->MatchTAG[$this->FirstTAG]['Replace'] ), $Match[0] ); if ( in_array( $this->FirstTAG, array( 'FE', 'FF', 'IF', 'ELIF', 'ELSE' ) ) ) $this->TabCount++; if ( in_array( $this->FirstTAG, array( 'FE', 'FF' ) ) ) $this->TabCount++; if ( in_array( $this->FirstTAG, array( 'IF', 'ELIF', 'PHP' ) ) ) $FunctionGlobals[] = $Match[1]; if ( in_array( $this->FirstTAG, array( 'FE', 'FF', 'VAR' ) ) ) $FunctionGlobals[] = "$" . $Match[1]; } } else { if ( trim( $HtmlCode = substr( $Content, 0, $StartPoint ) ) != "" ) { if ( $HtmlOpen ) $FunctionCode .= " . "; else $FunctionCode .= $this->addTab() . "\$_HTML .= "; $HtmlOpen = true; $FunctionCode .= "'" . str_replace( "'", "\'", $HtmlCode ) . "'"; $Content = substr( $Content, strlen( $HtmlCode ), strlen( $Content ) - strlen( $HtmlCode ) ); } else $Content = ltrim( $Content ); } } if ( trim( $Content ) != '' ) { if ( $HtmlOpen ) $FunctionCode .= " . "; else $FunctionCode .= $this->addTab() . "\$_HTML .= "; $HtmlOpen = true; $FunctionCode .= "'" . str_replace( "'", "\'", $Content ) . "'"; } if ( $HtmlOpen ) $FunctionCode .= ";\r\n"; $Function = "function t_" . $Name . "(" . implode( ',', $FunctionVars ) . ")\r\n{\r\n"; $Function .= $this->setGlobals( $FunctionGlobals, $FunctionVars ); if ( substr( $FunctionCode, 0, 3 ) == " . " ) { $Function .= "\t\$_HTML = "; $Function .= substr( $FunctionCode, 3, strlen( $FunctionCode )-3 ) ; } else { $Function .= "\t\$_HTML = ''"; $Function .= $FunctionCode ; } $Function .= "\treturn \$_HTML;\r\n"; $Function .= "}\r\n"; $FunctionList[] = $Function; } return implode( "\r\n", $FunctionList ); } function getFirstTAG( $Content, $Offset = 0 ) { $FirstPosition = 999999; foreach ( $this->MatchTAG as $TagName => $TagArray ) { if ( ( $Position = strpos( $Content, "<" . $TagName, $Offset ) ) !== false ) { if ( $Position < $FirstPosition ) { $FirstPosition = $Position; $this->FirstTAG = $TagName; } } } if ( $FirstPosition < 999999 ) return $FirstPosition; else return false; } function addTab() { return str_repeat( "\t", $this->TabCount ); } function setGlobals( $GlobalArray, $VarsArray = array() ) { $Globals = array(); foreach ( $GlobalArray as $Global ) { preg_match( '/\$([a-z0-9_]+)/i', $Global, $Match ); if ( !isset( $Globals[$Match[1]] ) AND !in_array( $Match[1], $this->PredefinedGlobals ) AND !isset( $VarsArray[$Match[1]] ) ) $Globals[$Match[1]] = '$' . $Match[1]; } if ( count( $Globals ) ) return "\tglobal " . implode( ', ', $Globals ) . ";\r\n"; else return ""; } } ?> My school is running PHP 4.3.2 on its network, and I'm running PHP 5.3.1 on my localhost machine using Xampp/Apache. My login system works perfectly at school, however $_SESSION["LoggedIn"] does not register, recognise nor acknowledge on my home system. It's not the script itself as I've copied the files across, so in theory it should work exactly the same? I've compared phpinfo()'s and within the session category all values are the same. The database/MySQL works fine on both networks so it's not a problem to do with this. Any ideas? Thanks. Hey guys i need to create a function that scans the whole website and gets the total used size for each extenssion inside an array to then be able to use it this way <?php echo 'Total space used for MP3 '.$scan[mp3][size].' bytes'; echo 'Total space used for JPG '.$scan[jpg][size].' bytes'; echo 'Total space used for PHP '.$scan[php][size].' bytes'; /// [...] ?> what am i doing wrong? Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /****/*****/*/domains/klikertje.nl/public_html/adminpaneel/index.php on line 123 script of adminpaneel/index.php <?php include("../config.php"); include('../cronjobs.php'); $gebruikersnaam = "robin"; //De gewenste gebruikernaam $wachtwoord = "rg953gejFDI3c"; //Het gewenste wachtwoord if(preg_match('/^[a-zA-Z ]+$/D', $_SERVER['PHP_AUTH_USER']) == 0){ if(preg_match('/^[a-zA-Z ]+$/D', $_SERVER['PHP_AUTH_PW']) == 0){ if($_SERVER['PHP_AUTH_USER'] != $gebruikersnaam || $_SERVER['PHP_AUTH_PW'] != $wachtwoord) { header("WWW-Authenticate: Basic realm=\"Beveiliging\""); header("HTTP/1.0 401 Unauthorized"); echo "Je bent niet ingelogd! Probeer het <A HREF=\"javascript:location.reload();\">opnieuw</A>."; exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>MiljoenenMail</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="keywords" content="miljoenenmail" /> <meta name="description" content="MiljoenenMail" /> <meta http-equiv="content-language" content="nl" /> <link href="../css/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="containermain"> <div id="headercontainer"> <div id="headerleft"> <div id="logo"><img src="../images/miljoenenmaillogo.png"></div> <div id="menu"> <ul> <li class="first"><a href="index.php">Algemeen</a></li> <li><a href="afmelden.php">Uitloggen</a></li> <li><a href="profile.php">profiel</a></li> <li><a href="payout.php">Uitbetaling</a></li> </ul> </div> </div> <div id="headerright"> <center><i>Welkom Beheerder</i></center> <table border="0" width="235px" style="margin-top: 5px;" height="85px"> <tr><td><img src="images/parel.png" alt="Parel" /></td><td style="text-align:left;">Parels: <?=$gebruiker->parels?></td><td><img src="images/eurosymbol.png" alt="Euro" /></td><td style="text-align:left;"><?=$gebruiker->saldo?></td></tr> <tr><td><img src="images/klikmissie.png" alt="Kliknissie" /></td><td style="text-align:left;">Klikmissie</td><td><img src="images/wallet.png" alt="Uitbetalen"/></td><td style="text-align:left;">Uitbetalen</td></tr> <tr><td><img src="images/message.png" alt="Berichten" /></td><td style="text-align:left;">Berichten: <b><?=$gebruiker->berichten?></b></td><td><img src="images/nl_flag.png" alt="" /></td><td style="text-align:left;">Nederland</td></tr> 2 </table> </div> </div> <div id="floatheader"></div> <div id="tab_understroke"></div> <div id="container"> <div id="rechtscontainer"> <div id="topblue"></div> <div id="main"> <p><strong><h2>AdminPaneel</h2></strong></p> <hr /> <form name="form1" method="post" action=""> <table border="0"> <tr> <td>de nieuws/voorpagina wijzigen:</td> <?php if(!isset($_POST['Submit'])) { ?> <td><input name="nieuws" type="text" size="20" <?php if(isset($nieuws->inhoud)) { ?>value="<?=$nieuws->inhoud?>"<?php } ?>></td> </tr> <tr> <td colspan="2"> <input type="submit" name="Submit" value="Opslaan"> </td> </tr> </table> </form> <?php } else { if(isset($_POST['nieuws']) OR $_POST['nieuws'] !== $nieuws->inhoud ) { mysql_query("UPDATE cmssysteem SET inhoud='".$_POST['nieuws']."'"); } echo "bedankt voor je wijzigingen ze zijn succesvol opgeslagen en veel plezier verder met de site admin ;)"; } ?> </div> <div id="right"> <div class="title">Statistieken</div> <div class="right_content"> Aantal leden: <?=$leden?><br /> Leden online: <?=$leden?><br /> Totaal aantal parels: <?=$totaalparels?><br /> € 532,00 uitgekeerd! </div> </div> </div> <div id="float"></div> <div id="footer"></div> </div> </div> <center><table border="0" width="861px"> <tr><td align="left"><pre>© 2010 Miljoenenmail.nl</pre></td><td align="right"><pre>made by: Ismail Metaich</pre></td></tr> </table></center> </body> </html> <? } else { echo "<html><body>$_SERVER['PHP_AUTH_PW'] bevat cijfers of speciale tekens alleen letters mogelijk!</html></body>" } } else { echo "$_SERVER['PHP_AUTH_USER'] bevat cijfers of speciale tekens alleen letters mogelijk!"; } ?> I've tried to integrate PHPBB3 on my site, so far it works, I can use the forum login/logout and on the main page it says either "Thank you for logging in" or the buttons for "Logging in/Registering". However sometimes for no apparent reason this error is displayed at the very top of the page, logging in seems to remove it but logging out doesn't produce the error, it comes about after a few hours, everyone can see this error apparently until I/(possibly) they login: Code: [Select] [phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home/x/public_html/index.php:3) [phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home/x/public_html/index.php:3) [phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home/x/public_html/index.php:3) I ran into the error before when I was doing the integration and turned out that I wasn't putting part of the PHP code right at the top, so what could be causing this? Any help would be greatly appreciated! Thanks, otester I'm using simple html dom parser. I used it in my web site successfully. But i changed my host company and i can't run my existing codes. "file_get_html" works on some sites. doesn't work on some sites. i couldn't understand the problem. This one works: Code: [Select] include_once ('simple_html_dom.php'); $html1 = file_get_html('http://www.yahoo.com'); echo $html1; Although web site can be opened from my browser, This one doesn't work in php script: Code: [Select] include_once ('simple_html_dom.php'); $html2 = file_get_html('http://www.eksisozluk.com'); echo $html1; ----------------------------- The same problem occurs again when i use in object oriented way. Works: Code: [Select] $html1 = new simple_html_dom(); $address1='http://www.yahoo.com'; $html1->load_file($address1); echo "$html1"; Doesn't work: Code: [Select] $html2 = new simple_html_dom(); $address2='http://www.eksisozluk.com'; $html2->load_file($address2); echo "$html2"; The error is: Warning: file_get_contents(http://www.eksisozluk.com) [function.file-get-contents]: failed to open stream: HTTP request failed! in /home/mysite/public_html/myfolder/simple_html_dom.php on line 850 Fatal error: Call to a member function innertext() on a non-object in /home/mysite/public_html/myfolder/simple_html_dom.php on line 1364 Im trying to get a login/register script to work in my existing page design but im getting an error, i have no idea what im doing i know next to nothing about php, i just follow tutorials. Most of the error is hidden because the font is the same color as the background but is says: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/aretheyh/public_html/nealeweb.com/index.php:16) in /home/aretheyh/public_html/nealeweb.com/index.php on line 25 Heres the page link where the error occurs: http://www.nealeweb.com/index.php Please help, im useless! Hello, Ive got a fairly successful website and im looking at cloning it, I want to set up a cron to check the main site if there are any new posts and if there are insert it into the DB. Ive got them on 2 separate hosts so i don't want to just read from the DB increase the main site goes down and brings the whole 2nd site down. What would be the easiest way to do it? Not looking for people to give code, Just their suggestions. Cheers I was wondering if anyone is aware of a php script that can pull html from a external site and create a local page with all the urls and image paths rewritten to local paths. I'm trying to create a module for Drupal that does this. Any script already written that I can adapt to Drupal would be great. If no one is aware of a current script that does this, can anyone point me in the right direction? Hey all. I've created a script that updates a website's config in a database. The script itself works fine but I feel it is rather uncanny. Where can I look to find better methods of achieving what I'm trying to accomplish? Here's my script that updates my table with columns id, showlogin, colorscheme, blogmenu, aboutus. I explain the script below it. if (isset($_POST['submit'])) { // id will always be 1 and only query if only submit was pressed $sql = "UPDATE config SET id=1"; // showlogin values are 1 for show login form and 2 for don't if(!empty($_POST['showlogin'])) { $showlogin = $_POST['showlogin']; $sql .= ", showlogin='$showlogin'"; } if(!empty($_POST['colorscheme'])) { $colorscheme = $_POST['colorscheme']; $sql .= ", colorscheme='$colorscheme'"; } if(!empty($_POST['blogmenu'])) { $blogmenu = $_POST['blogmenu']; $sql .= ", blogmenu='$blogmenu'"; } else { $sql .= ", blogmenu=2"; } if(!empty($_POST['aboutus'])) { $aboutus = $_POST['aboutus']; $sql .= ", aboutus='$aboutus'"; } else { $sql .= ", aboutus=2"; } mysql_query($sql, $connect) or die (mysql_error()); } It works like this. I have a form with a few selects and checkboxes. The selects are the colorscheme and showlogin. The checkboxes are blogmenu and about us, both defaulting to the number 2 if they are not checked. 1 means show this item on the live site and 2 means do not show. This is pulled out of the database on page loads. So, I hope I was clear as my mind is spaghetti right now. Cheers! I have approximately 2,300 videos embedded on my site, and I am constantly adding more. The videos are hosted by YouTube. When a video is deleted from YouTube, it becomes unavailable on my site. Each video's ID is in my MySQL database. A video ID looks like this: ZFOuxAx-dkc I need a script that will do the following: select the IDs from my database check if the videos are still available on YouTube create a list of the videos that are unavailable. If possible, it would be great if the script could also tell me if any of the videos have been blocked in certain countries. The script has to be fully commented so that I can understand it. I want to run the script manually every few days. I don't want to have to change my database tables. I've been told that you can use YouTube's API or YouTube's oEmbed interface. I've also been told that, because there are so many videos, you will have to use cURL multi handles. If interested in this project, please PM me your price. This is an urgent project. I have placed ads elsewhere. I wrote this basic script yesterday to process and generate a Google Site Map. And it works! BUT I want to advance this script to accommodate for something else and I don't know the correct path to take from here, but I will tell you what I've found out so far.. Current Situation: 1 - Currently my below script generates urls in the site map like: http://abcdefg.com/index.php?dispatch=products.view&product_id=29826 2 - I have .htaccess configured to rewrite the urls to the products name data like: http://abcdefg.com/pennies/wheat-pennies/lincoln-wheat-penny-cent.html (just an example) and these urls are ONLY active if clicking on the site links themselves - meaning if I enter: http://abcdefg.com/index.php?dispatch=products.view&product_id=29826 directly into the url, the url does not resolve to this natural friendly url name. What Id like to achieve (which I don't know what direction I should be looking!): - I'd like my xml output urls (as current) to be written in the natural format (as in #2 above). FYI here is a current example output item in my sitemap: Code: [Select] <url> <loc>http://abcdefg.com/index.php?dispatch=products.view&product_id=29803</loc> <changefreq>weekly</changefreq> <lastmod>2010-09-24T08:00:00+04:00</lastmod> </url> Can anyone give me some guidance on what method might work for this? Do you think it's more a mod_rewrite issue? Or can this be handled easier with straight up modifications to my below? I'm just a bit confused on what direction I should be looking.. Thanks for any input. <?php header("Content-Type: text/xml;charset=iso-8859-1"); echo '<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; //include('config.local.php'); $cxn = mysqli_connect($config['db_host'], $config['db_user'], $config['db_password'], $config['db_name']); $query = "SELECT cscart_product_descriptions.product_id, cscart_products.product_id, cscart_products.timestamp FROM cscart_product_descriptions JOIN cscart_products ON cscart_product_descriptions.product_id = cscart_products.product_id WHERE cscart_products.status='A' LIMIT 10000"; $result = mysqli_query($cxn, $query); $row = mysqli_fetch_array($result); while ($row = mysqli_fetch_array($result)) { $formatedTime = $row['timestamp']; echo '<url> <loc>http://abcdefg.com/index.php?dispatch=products.view&product_id=' . $row['product_id'] . '</loc> <changefreq>weekly</changefreq> <lastmod>'. date('c',$formatedTime) .'</lastmod> </url>'; } //while ($row = mysqli_fetch_array($result)) echo '</urlset>'; ?> Nothing fancy, I am just looking for a simple php script that would check a text file on my server that has a bunch of domains in it. I want the script to ping a random 5 or 10 sites in the list, and then redirects the visitor to the fastest one, or at least one that responds, and is not down. If all that are checked are down, then it would need to recheck the list. I want it to pick random domains out of the list, as I don't want users directed to the same site(s) all the time, just because it pings the best. When I say ping, I am talking about making sure the user isn't directed to a website that is down, or a slow loading website. I am not sure if "ping" is the correct word for that tho? Can anybody offer me code like this for free, or is this type of request getting into something that would need to be paid code? (and if so, any idea how much? I didn't post this in the freelancing forum, because it sounds like it might be something simple to code. I am not a coder, so I am looking for something complete that I can add to a php file and it works. Thanks for any code, pointers/problems with this idea, or price quotes (if necessary) on this little script I am looking for. |