PHP - Problem After Migrating From V5.2 To 5.3
Hi all, please be nice my php is poor!
I operate a website which uses the JS menue from Milonic, As part of the package from Milonic there is a function to output the menu as a site map this uses some clever php jiggery pokery.... I have recently changed hosts to a new host offering only php v5.3, i have noticed that the sitemap now will not run, to my unknowledgeable eyes it seems to get part way through the code then output the rest as text.... see... www.tugtracker.co.uk/menu/extras/php_sitemap/index.php Code: [Select] html> <body> This file needs to be executed under PHP from a webserver and will take the <br> contents of any Milonic menu data file and output the results as either a <br> NoScript menu or as a Sitemap <? //$menuDataFile[]="http://www.milonic.com/menu_data.php"; // Can execute a WWW File $menuDataFile[]="http://www.tugtracker.co.uk/menu/embedded_main_menu.js"; // Or can execute a local file //$menuDataFile[]="/main_menu_data.php"; // You can also add more than one file //$menuDataFile[]="/menu_data.php"; // For main and sub menus if you need to $useMenuStyles=false; include("http://www.tugtracker.co.uk/menu/extras/php_sitemap/mm_dataminer.php"); echo "<Pre>".outputAsSiteMap($menuDataFile)."</Pre>"; // Can output as a Sitemap //echo "<PRE>".outputAsNoScript($menuDataFile)."</PRE>"; // Or output as a NoScript Sitemap ?> </body> </html> The dataminer code file is Code: [Select] <? /* Milonic DHTML/PHP Menu Sitemap builder version 2.0 - September 1 2006 mm_dataminer.php */ //$globalValues=Array(); //$menus=Array(); //$styles=Array(); //$filedata=""; $dataRetrieved=0; $_S=Array(); $_M=Array(); $_I=Array(); function extractStyleName($data) { global $filedata; $pos=miner_getInnerStrpos($data, "(", "="); $text=substr($data,$pos[0]+1, $pos[1]-2); $pos=miner_getInnerStrpos($data, "with(", "mm_style("); $filedata=substr($filedata,0,$pos[0]).substr($filedata,$pos[1]+9,strlen($filedata)); return $text; } function extractMenuName($data){ if(substr($data,0,1)=="(")$data=substr($data,1,strlen($data)); $pos=miner_getInnerStrpos($data, "(\"", "\")"); $text=substr($data,$pos[0]+1, $pos[1]-2); $text=ereg_replace("\"", "", $text); return $text; } function getThisFile(){ $getThisFile=$_SERVER['SCRIPT_NAME']; $pos=strrpos($getThisFile,"/"); if($pos)$getThisFile=substr($getThisFile,$pos+1); return $getThisFile; } function getThisFolder(){ $thisfile=getThisFile(); $thisFolder=$_SERVER['SCRIPT_NAME']; if(strlen($thisfile)>0)$thisFolder=ereg_replace($thisfile,"",$thisFolder); return $thisFolder; } function createMenuStyleCSS() { global $styles; $cssoutput="<style>"; $styleproperties=""; foreach ($styles as $key => $value) { foreach ($value as $cssproperty => $cssvalue) { if($cssproperty=="stylename")$stylename=$cssvalue; if($cssproperty=="offcolor")$styleproperties.="color:$cssvalue;"; if($cssproperty=="offbgcolor")$styleproperties.="background-color:$cssvalue;"; if($cssproperty=="fontfamily")$styleproperties.="font-family:$cssvalue;"; if($cssproperty=="fontsize")$styleproperties.="font-size:$cssvalue;"; } $cssoutput.= ".".$stylename."{".$styleproperties."}"; } $cssoutput.="</style>"; echo $cssoutput; } $RitemsArray=Array(); function getRecursiveItemsByMenuname($menuname, $datafile, $level=0, $counter=1){ global $menus,$RitemsArray; $menus=getMenusFromData($datafile); //echo "<HR>".count($menus)."<HR>"; for($a=0;$a<count($menus);$a++){ if($menus[$a]['menuname']==$menuname){ for($b=0;$b<count($menus[$a]['items']);$b++){ $RitemsArray[]['level']=$level; $RitemsArray[count($RitemsArray)-1]['data']=$menus[$a]['items'][$b]; $RitemsArray[count($RitemsArray)-1]['data']['menu']=$a; if(isset($menus[$a]['items'][$b]['showmenu'])&& $menus[$a]['items'][$b]['showmenu']) { getRecursiveItemsByMenuname($menus[$a]['items'][$b]['showmenu'],$datafile,$level+1, $counter,$datafile); } } } } return $RitemsArray; } function getFormatedMenuDataFromFile($menufile){ global $globalValues, $styles, $menus, $filedata; $menus=Array(); if(!$menufile)$menufile="menu_data.js"; if (ereg("://", $menufile)){ $handle = fopen($menufile, "rb"); $contents = ''; if($handle){ while (!feof($handle)){ $contents .= fread($handle, 8192); } } fclose($handle); $filedata=$contents; } else{ $menufile=$_SERVER['DOCUMENT_ROOT'].$menufile; $contents = ''; if ($handle=fopen($menufile, "rb")){ while(!feof($file)){ $contents .= fread($handle, 8192); } } fclose($handle); $filedata=$contents; } if(strlen($filedata)>1) { $filedata=stripslashes($filedata); $filedata=ereg_replace("://",":",$filedata); $filedata=miner_replaceInnerText($filedata, "\"", "\"", ";", "", 1); $filedata=miner_chopInnerText($filedata, "/*", "*/", 1, 0); $filedata=miner_chopInnerText($filedata, "//", "\r", 1, 0); $filedata=ereg_replace("\t","",$filedata); $filedata=miner_replaceInnerText($filedata, "\"", "\"", "with", "_H_T_I_W_", 1); $filedata=miner_replaceInnerText($filedata, "\"", "\"", "{", "_OPEN_CUR_BRA_CKET_", 1); $filedata=miner_replaceInnerText($filedata, "\"", "\"", "}", "_CLOSE_CUR_BRA_CKET_", 1); $filedata=ereg_replace("\n",";",$filedata); $filedata=ereg_replace("\r",";",$filedata); $filedata=ereg_replace(" {2,}", " ", $filedata); $filedata=ereg_replace(" ;",";",$filedata); $filedata=ereg_replace("; ",";",$filedata); $filedata=ereg_replace("= ","=",$filedata); $filedata=ereg_replace(" =","=",$filedata); $filedata=ereg_replace(":","://",$filedata); $globalValues["_menuCloseDelay"]=extractPair("_menuCloseDelay",$filedata); $globalValues["_menuOpenDelay"]=extractPair("_menuOpenDelay",$filedata); $globalValues["_subOffsetTop"]=extractPair("_subOffsetTop",$filedata); $globalValues["_subOffsetLeft"]=extractPair("_subOffsetLeft",$filedata); $globalValues["disableMouseMove"]=extractPair("disableMouseMove",$filedata); $globalValues["ignoreCollisions"]=extractPair("ignoreCollisions",$filedata); $globalValues["horizontalMenuDelay"]=extractPair("horizontalMenuDelay",$filedata); $globalValues["retainClickValue"]=extractPair("retainClickValue",$filedata); $globalValues["closeAllOnClick"]=extractPair("closeAllOnClick",$filedata); $globalValues["noSubImageSpacing"]=extractPair("noSubImageSpacing",$filedata); $globalValues["includeTabIndex"]=extractPair("includeTabIndex",$filedata); $globalValues["buildAllMenus"]=extractPair("buildAllMenus",$filedata); $globalValues["_CFix"]=extractPair("_CFix",$filedata); $globalValues["blankPath"]=extractPair("blankPath",$filedata); $globalValues["_scrollUpImage"]=extractPair("_scrollUpImage",$filedata); $globalValues["_scrollDownImage"]=extractPair("_scrollDownImage",$filedata); $globalValues["_scrollAmount"]=extractPair("_scrollAmount",$filedata); $globalValues["_scrollDelay"]=extractPair("_scrollDelay",$filedata); $data=split("with",$filedata); $stylecount=0; $menucount=0; //echo count($data); for($a=0;$a<count($data);$a++) { if(eregi("new mm_style\(\)", $data[$a])) { $stylename=extractStyleName($data[$a]); $styles[$stylecount]["stylename"]=$stylename; $props=miner_getInnerText($data[$a], "{", "}"); $propsar=split(";",$props); for($b=0;$b<count($propsar);$b++){ $pos=strpos($propsar[$b],"="); if($pos){ $key=substr($propsar[$b],0,$pos); $styles[$stylecount][$key]=extractPair($key,$data[$a]); } } $stylecount++; } if(eregi("new menuname\(", $data[$a])) { $menuname=extractMenuName($data[$a]); $menus[$menucount]["menuname"]=$menuname; $props=miner_getInnerText($data[$a], "{", "}"); $propsar=split(";",$props); $itemnumber=0; for($b=0;$b<count($propsar);$b++){ if(substr($propsar[$b],0,3)=="aI("){ $aitext=substr(miner_getInnerText($propsar[$b], "\"", "\""),1,strlen($propsar[$b])-6); $aiparts=split("",$aitext); for($c=0;$c<count($aiparts);$c++){ $pos=strpos($aiparts[$c],"="); if($pos){ $key=substr($aiparts[$c],0,$pos); $val=substr($aiparts[$c],$pos+1,strlen($aiparts[$c])); $menus[$menucount]['items'][$itemnumber][$key]=$val; $lastGoodItem=$itemnumber; $lastGoodKey=$key; } else{ if($aiparts[$c]){ $menus[$menucount]['items'][$lastGoodItem][$lastGoodKey].=";".$aiparts[$c]; } } } $itemnumber++; } else{ $pos=strpos($propsar[$b],"="); if($pos){ $key=substr($propsar[$b],0,$pos); $menus[$menucount][$key]=extractPair($key,$data[$a]); } } } $menucount++; } } } return $filedata; } function getMenusFromData($datafile) { global $_M; $menus=Array(); $menucount=0; $data=split("with",$datafile); for($a=0;$a<count($data);$a++) { if(eregi("new menuname\(", $data[$a])) { $menuname=extractMenuName($data[$a]); $menus[$menucount]["menuname"]=$menuname; $props=miner_getInnerText($data[$a], "{", "}"); $propsar=split(";",$props); $itemnumber=0; for($b=0;$b<count($propsar);$b++){ if(substr($propsar[$b],0,3)=="aI("){ $aitext=substr(miner_getInnerText($propsar[$b], "\"", "\""),1,strlen($propsar[$b])-6); $aiparts=split("",$aitext); $menus[$menucount]['items'][$itemnumber]['menu']=$menucount+count($_M); for($c=0;$c<count($aiparts);$c++){ $pos=strpos($aiparts[$c],"="); if($pos){ $key=substr($aiparts[$c],0,$pos); $val=substr($aiparts[$c],$pos+1,strlen($aiparts[$c])); $val=ereg_replace("_H_T_I_W_","with",$val); $menus[$menucount]['items'][$itemnumber][$key]=$val; $lastGoodItem=$itemnumber; $lastGoodKey=$key; } else{ if($aiparts[$c]){ $menus[$menucount]['items'][$lastGoodItem][$lastGoodKey].=";".$aiparts[$c]; } } } $itemnumber++; } else{ $pos=strpos($propsar[$b],"="); if($pos){ $key=substr($propsar[$b],0,$pos); $menus[$menucount][$key]=extractPair($key,$data[$a]); } } } $menucount++; } } return $menus; } function getSiteMapData($datafile) { global $globalValues, $styles, $menus, $useMenuStyles; $oldlevel=0; $menus=""; $data=getFormatedMenuDataFromFile($datafile); echo "<PRE style='color:red;background:#c0c0c0'>$data</PRE>"; $output=""; $mainmenus=getMainMenus(); //echo count($mainmenus)."<HR>"; if($useMenuStyles)createMenuStyleCSS(); for($a=0;$a<count($mainmenus);$a++)$items=getRecursiveItemsByMenuname($mainmenus[$a]); //echo count($items)."<HR>"; $output.="<UL>"; for($a=0;$a<count($items);$a++) { $leveldifference=$items[$a]['level']-$oldlevel; if($leveldifference>0)for($x=0;$x<$leveldifference;$x++)$output.= "<UL>\n"; if($leveldifference<0)for($x=0;$x>$leveldifference;$x--)$output.= "</UL>\n"; $item=$items[$a]['data']; $itemHTML=""; if($item['text']) { $itemHTML=ereg_replace("_H_T_I_W_","with",$item['text']); if(isset($item['image'])&&$item['image'])$itemHTML="<img src=".$item['image']." border=0>".$itemHTML; } else { } if(isset($item['url'])&&$item['url'])$itemHTML="<a href=".$item['url'].">".$itemHTML."</a>"; $mstyle=$menus[$item['menu']]['style']; $output.= "<LI class=$mstyle>$itemHTML\n"; $oldlevel=$items[$a]['level']; } $output.="</UL>"; return $output; } function getGlobalsFromData($datafile) { $menuGlobals=Array(); $menuGlobals["_menuCloseDelay"]=extractPair("_menuCloseDelay",$datafile); $menuGlobals["_menuOpenDelay"]=extractPair("_menuOpenDelay",$datafile); $menuGlobals["_subOffsetTop"]=extractPair("_subOffsetTop",$datafile); $menuGlobals["_subOffsetLeft"]=extractPair("_subOffsetLeft",$datafile); $menuGlobals["disableMouseMove"]=extractPair("disableMouseMove",$datafile); $menuGlobals["ignoreCollisions"]=extractPair("ignoreCollisions",$datafile); $menuGlobals["horizontalMenuDelay"]=extractPair("horizontalMenuDelay",$datafile); $menuGlobals["retainClickValue"]=extractPair("retainClickValue",$datafile); $menuGlobals["closeAllOnClick"]=extractPair("closeAllOnClick",$datafile); $menuGlobals["noSubImageSpacing"]=extractPair("noSubImageSpacing",$datafile); $menuGlobals["includeTabIndex"]=extractPair("includeTabIndex",$datafile); $menuGlobals["buildAllMenus"]=extractPair("buildAllMenus",$datafile); $menuGlobals["_CFix"]=extractPair("_CFix",$datafile); $menuGlobals["blankPath"]=extractPair("blankPath",$datafile); $menuGlobals["_scrollUpImage"]=extractPair("_scrollUpImage",$datafile); $menuGlobals["_scrollDownImage"]=extractPair("_scrollDownImage",$datafile); $menuGlobals["_scrollAmount"]=extractPair("_scrollAmount",$datafile); $menuGlobals["_scrollDelay"]=extractPair("_scrollDelay",$datafile); return $menuGlobals; } ################################################################################ function getStylesFromData($datafile) { $styles=Array(); $stylecount=0; $data=split("with",$datafile); for($a=0;$a<count($data);$a++) { if(eregi("new mm_style\(\)", $data[$a])) { $stylename=extractStyleName($data[$a]); $styles[$stylecount]["stylename"]=$stylename; $props=miner_getInnerText($data[$a], "{", "}"); $propsar=split(";",$props); for($b=0;$b<count($propsar);$b++){ $pos=strpos($propsar[$b],"="); if($pos){ $key=substr($propsar[$b],0,$pos); $styles[$stylecount][$key]=extractPair($key,$data[$a]); } } $stylecount++; } } return $styles; } function extractPair($data, $filedata){ if(!strpos($filedata, $data))return ""; $data=ereg_replace(" =","=",$data); $data=ereg_replace("= ","=",$data); $text=miner_getInnerText($filedata, $data."=", ";"); $text=substr($text,strlen($data)+1,strrpos($text,";")-strlen($data)-1); $filedata=miner_chopInnerText($filedata, $data, ";", 0,0); $text=ereg_replace("\"", "", $text); return $text; } function miner_replaceInnerText($haystack, $startNeedle, $endNeedle, $needle, $newneedle, $loopthru=0) { /* This function replaces text inside a specified block of text */ $pstr=$haystack; $pos=miner_getInnerStrpos($haystack,$startNeedle, $endNeedle); if(is_numeric($pos[0]) && is_numeric($pos[1])){ if($loopthru){ $tstr=$haystack; $pstr=""; while(is_numeric($pos[0]) && is_numeric($pos[1])){ $istr=substr($tstr,$pos[0],$pos[1]); $istr=ereg_replace($needle,$newneedle,$istr); $pstr.=substr($tstr,0,$pos[0]).$istr; $tstr=substr($tstr,$pos[0]+$pos[1],strlen($tstr)); $pos=miner_getInnerStrpos($tstr, $startNeedle, $endNeedle); } $pstr.=substr($tstr,0,strlen($tstr)); } else{ $pstr=substr($haystack,$pos[0],$pos[1]); $pstr=ereg_replace($needle,$newneedle,$pstr); $pstr=substr($haystack,0,$pos[0]).$pstr.substr($haystack,$pos[1]+$pos[0],strlen($haystack)); } } return $pstr; } function miner_getInnerStrpos($haystack, $startNeedle, $endNeedle) { $pos1=strpos($haystack, $startNeedle); $startNeedleWidth=strlen($startNeedle); $tstr=substr($haystack,$pos1+$startNeedleWidth,strlen($haystack)); $pos2=strpos($tstr, $endNeedle); if(is_numeric($pos2))$pos2=$pos2+strlen($startNeedle)+strlen($endNeedle); $spos[0]=$pos1; $spos[1]=$pos2; return $spos; } function miner_chopInnerText($haystack, $startNeedle, $endNeedle, $loopthru=1, $keepvars=0) { $pstr=$haystack; $pos=miner_getInnerStrpos($haystack, $startNeedle, $endNeedle); if(is_numeric($pos[0]) && is_numeric($pos[1])){ if($loopthru){ $tstr=$pstr; $pstr=""; while(is_numeric($pos[0]) && is_numeric($pos[1])){ if($keepvars){ $pstr.=substr($tstr,0,$pos[0]+strlen($startNeedle)); $tstr=substr($tstr,$pos[0]+$pos[1],strlen($tstr)); } else{ $pstr.=substr($tstr,0,$pos[0]); $tstr=substr($tstr,$pos[0]+$pos[1],strlen($tstr)); } $pos=miner_getInnerStrpos($tstr, $startNeedle, $endNeedle); } $pstr.=substr($tstr,0,strlen($tstr)+1); } else{ if($keepvars){ $pstr=substr($haystack,0,$pos[0]+strlen($startNeedle)); $pstr.=substr($haystack,$pos[1]+$pos[0]-strlen($endNeedle),strlen($haystack)); } else{ $pstr=substr($haystack,0,$pos[0]); $pstr.=substr($haystack,$pos[1]+$pos[0],strlen($haystack)); } } } return $pstr; } function miner_getInnerText($haystack, $startNeedle, $endNeedle, $includeNeedles=1) { $pos=miner_getInnerStrpos($haystack,$startNeedle, $endNeedle); $pstr=substr($haystack,$pos[0],$pos[1]); if(!$includeNeedles){ $pstr=substr($pstr,strlen($startNeedle),strlen($pstr)); $pstr=substr($pstr,0,strlen($pstr)-strlen($endNeedle)); } return $pstr; } function getDocumentRoot(){ $docRoot=$_SERVER['DOCUMENT_ROOT']; if(substr($docRoot,-1)!="/")$docRoot.="/"; return $docRoot; } function getMenuTextFromDataFile($filename) { $filedata=""; if (ereg("://", $filename)){ $handle = fopen($filename, "rb"); } else { //$filename=getDocumentRoot().$filename; //echo $filename; $handle = fopen($filename, "rb"); } $contents=""; if ($handle){ while(!feof($handle)) { $contents .= fread($handle, 8192); } } else { echo "<br><b>Couldn't open file: $filename</b><br>"; return; } fclose($handle); $filedata=$contents; if(strlen($filedata)>1) { $filedata=stripslashes($filedata); $filedata=ereg_replace("://",":",$filedata); $filedata=miner_replaceInnerText($filedata, "\"", "\"", ";", "", 1); $filedata=miner_chopInnerText($filedata, "/*", "*/", 1, 0); $filedata=miner_chopInnerText($filedata, "//", "\r", 1, 0); $filedata=ereg_replace("\t","",$filedata); $filedata=miner_replaceInnerText($filedata, "\"", "\"", "with", "_H_T_I_W_", 1); $filedata=miner_replaceInnerText($filedata, "\"", "\"", "{", "_OPEN_CUR_BRA_CKET_", 1); $filedata=miner_replaceInnerText($filedata, "\"", "\"", "}", "_CLOSE_CUR_BRA_CKET_", 1); $filedata=ereg_replace("\n",";",$filedata); $filedata=ereg_replace("\r",";",$filedata); $filedata=ereg_replace(" {2,}", " ", $filedata); $filedata=ereg_replace(" ;",";",$filedata); $filedata=ereg_replace("; ",";",$filedata); $filedata=ereg_replace("= ","=",$filedata); $filedata=ereg_replace(" =","=",$filedata); $filedata=ereg_replace(":","://",$filedata); $filedata=ereg_replace(";{2,}", ";", $filedata); } return $filedata; } function getMenuData($reset=0) { global $_S; global $_M; global $_I; global $dataRetrieved; global $menuDataFile; if(!$dataRetrieved||$reset==1) { $_M = Array(); $_S = Array(); $_I = Array(); $menuCounter=0; $styleCounter=0; $itemCounter=0; for($df=0;$df<count($menuDataFile);$df++) { $dataText=getMenuTextFromDataFile($menuDataFile[$df]); $styles=getStylesFromData($dataText); for($a=0;$a<count($styles);$a++) { $_S[$styleCounter]=Array(); foreach ($styles[$a] as $key => $value) { $_S[$styleCounter][$key]=$value; } $styleCounter++; } $menus=getMenusFromData($dataText); for($a=0;$a<count($menus);$a++){ $_M[$menuCounter]=Array(); foreach ($menus[$a] as $key => $value) { $_M[$menuCounter][$key]=$value; } $menuCounter++; } } } $dataRetrieved=1; } function getItemsByMenu($mnu) { global $_M, $_S, $_I; $items=$_M[$mnu]['items']; for($a=0;$a<count($items);$a++) { echo "$items[$a]<br>"; } } function getMenuByName($menuname) { global $_M, $_S, $_I; for($a=0;$a<count($_M);$a++) { if($menuname==$_M[$a]['menuname'])return $a; } return -1; } $dataMinerOutput=""; // Global Variable for containing details of output function outputSitemapItems($mnu) { global $_M,$dataMinerOutput; $dataMinerOutput.="<UL>\n"; $items=$_M[$mnu]['items']; for($a=0;$a<count($items);$a++) { $dataMinerOutput.="<li>\n"; if(isset($items[$a]['showmenu'])&&$items[$a]['showmenu']) { //Changed www.snipperdag.com aI(text showmenu and url 16 September 2007 if(isset($items[$a]['url'])&&$items[$a]['url']) { $dataMinerOutput.="<a href=".$items[$a]['url'].">".$items[$a]['text']."</a>\n"; } else{ $dataMinerOutput.=$items[$a]['text']."\n"; } //Changed www.snipperdag.com aI(text showmenu and url) url was not linked 16 September 2007 outputSitemapItems(getMenuByName($items[$a]['showmenu'])); } else { if(isset($items[$a]['url'])&&$items[$a]['url']) { $dataMinerOutput.="<a href=".$items[$a]['url'].">".$items[$a]['text']."</a>\n"; } else { $dataMinerOutput.="".$items[$a]['text']."\n"; } } } $dataMinerOutput.="</UL>\n"; }unction outputSitemapItems($mnu) { global $_M,$dataMinerOutput; $dataMinerOutput.="<UL>\n"; $items=$_M[$mnu]['items']; for($a=0;$a<count($items);$a++) { $dataMinerOutput.="<li>\n"; if(isset($items[$a]['showmenu'])&&$items[$a]['showmenu']) { //Changed www.snipperdag.com aI(text showmenu url 16 September 2007 if(isset($items[$a]['url'])&&$items[$a]['url']) { $dataMinerOutput.="<a href=".$items[$a]['url'].">".$items[$a]['text']."</a>\n"; } else{ $dataMinerOutput.=$items[$a]['text']."\n"; } //Changed www.snipperdag.com I(text showmenu url) url was not linked 16 September 2007 outputSitemapItems(getMenuByName($items[$a]['showmenu'])); } else { if(isset($items[$a]['url'])&&$items[$a]['url']) { $dataMinerOutput.="<a href=".$items[$a]['url'].">".$items[$a]['text']."</a>\n"; } else { $dataMinerOutput.="".$items[$a]['text']."\n"; } } } $dataMinerOutput.="</UL>\n"; } function outputNoScriptItems($mnu) { global $_M,$dataMinerOutput; $items=$_M[$mnu]['items']; $dataMinerOutput.=""; for($a=0;$a<count($items);$a++) { if(isset($_M[$mnu]['orientation'])&& $_M[$mnu]['orientation']) { if($a==0)$dataMinerOutput.="<table border=0 cellpadding=0 cellspacing=0><tr>"; $lnk=$items[$a]['text']; if(isset($items[$a]['url'])&&$items[$a]['url']) { $lnk="<a href=".$items[$a]['url'].">".$items[$a]['text'].""; } $dataMinerOutput.="<td valign=top><b>$lnk</b>"; if(isset($items[$a]['showmenu'])&&$items[$a]['showmenu']) { outputSitemapItems(getMenuByName($items[$a]['showmenu'])); } $dataMinerOutput.="</td>"; if($a==count($items))$dataMinerOutput.="</tr></table>"; } } $dataMinerOutput.=""; } function outputAsNoScript($datafile=null) { global $_M,$dataMinerOutput; $mainmenus=getMainMenus(); for($a=0;$a<count($mainmenus);$a++) { // Need to get system to scan through menus see if they are horiz or vert and draw TABLE for horiz or UL for vertical $dataMinerOutput=""; outputNoScriptItems($mainmenus[$a]); echo $dataMinerOutput; echo "<HR>"; } } function getStyles() { global $_S; getMenuData(); return $_S; } function showStyles($datafile) { global $_M, $_S, $_I; $styles=getStyles(); for($a=0;$a<count($styles);$a++) { echo "<b>".$_S[$a]['stylename']."</b><br>"; foreach ($_S[$a] as $key => $value) { if(!is_numeric($value))$value="\"".$value."\""; echo "<b>$key</b>=$value;<br />\n"; } echo "<HR>"; } } function getMainMenus() { global $_M, $_S, $_I; getMenuData(); $mainmenus = Array(); for($a=0;$a<count($_M);$a++) { if(isset($_M[$a]['alwaysvisible'])&&$_M[$a]['alwaysvisible'])$mainmenus[]=$a; } return $mainmenus; } function showMainMenus() { global $_M, $_S, $_I; $mainmenus=getMainMenus(); for($a=0;$a<count($mainmenus);$a++) { echo "<b>".$_M[$a]['menuname']."</b><br>"; foreach ($_M[$a] as $key => $value) { echo "$key=$value<br>"; } echo "<HR>"; } } function getItems() { global $_M; getMenuData(); $items=Array(); $itemCounter=0; for($a=0;$a<count($_M);$a++) { foreach ($_M[$a]['items'] as $key1 => $value1) { foreach ($value1 as $key => $value) { $items[$itemCounter][$key]=$value; } $itemCounter++; } } return $items; } function showItems() { $items=getItems(); for($a=0;$a<count($items);$a++) { foreach ($items[$a] as $key => $value) { echo "$key=$value "; } echo "<br>"; } } function getAllMenus() { global $_M; getMenuData(); return $_M; } function showAllMenus($datafile) { global $_M, $_S, $_I; $menus=getAllMenus(); for($a=0;$a<count($menus);$a++) { echo "<b>".$_M[$a]['menuname']."</b><br>"; foreach ($_M[$a] as $key => $value) { echo "$key=$value<br>"; } echo "<HR>"; } } function showMenusAndItems($datafile) { global $_M, $_S, $_I; getMenuData(); for($a=0;$a<count($_M);$a++) { echo "<b>".$_M[$a]['menuname']."</b><br>"; foreach ($_M[$a] as $key => $value) { echo ".....$key=$value<br>"; } foreach ($_M[$a]['items'] as $key1 => $value1) { echo "..........."; foreach ($value1 as $key => $value) { echo "$key=$value--"; } echo "<br>"; } } echo "<hr>"; } function newShowMenus() { global $_M, $_S, $_I; getMenuData(); for($a=0;$a<count($_S);$a++) { echo "<b>".$_S[$a]['stylename']."</b><br>"; foreach ($_S[$a] as $key => $value) { echo ".....$key=$value<br>"; } } echo "<HR>"; for($a=0;$a<count($_M);$a++) { echo "<b>".$_M[$a]['menuname']."</b><br>"; foreach ($_M[$a] as $key => $value) { echo ".....$key=$value<br>"; } foreach ($_M[$a]['items'] as $key1 => $value1) { echo ".........."; foreach ($value1 as $key => $value) { echo "$key=$value--"; } echo "<br>"; } } } ?> I have another site which gives the option at the host of changing from 5.2 to 5.3 the map fnction works in 5.2 but gives the same error when i set the php version to 5.3.... To see it in action (different site to the one i am having probs with) see http://79.170.40.43/locodocs.co.uk/misc/sitemap.php I would appreciate any thoughts regards this matter, i have of course asked milonic, but as the sitemap util is part of the extras, they dont support it as such! Similar TutorialsA while back my webhost upgraded to PHP5 and broke a few of my simple scripts - primarily forms using a text box for entry. I renamed and relinked the forms to .php4 and it "solved" the problem. I've decided to fix them correctly and use proper PHP 5 code. What's the easiest way to actually retrieve the value of a text input in PHP5? My old reference tricks return null. When I started reading up I saw only PHP4 examples and then in over my head with global variables, httaccess and php.ini. I don't want to mess about with the default settings. I'm sure I zoomed right past a simple answer on my way to that mess. A simple example script: Code: [Select] <FORM NAME="form1" ID="form1" METHOD="POST" ACTION="simple.php"> <INPUT Type='Text' Name="i1Text" ID="i1Text" Value="Default"> <INPUT Type="Submit" Name="Submit1" Value="Read the Text"> </FORM> <?PHP if (isset($_POST['Submit1'])) { $RefText=$i1Text; print "Text: $RefText"; <!-- Returns blanks unless .php4 --> } ?>So, how do I actually get to that text value? Thanks in advance! Hi, I am trying to migrate my project from mysql to mysqli but with little knowledge of the later. Among the noticeable errors is that the code is no longer fetching data from the database, and I am also getting UNDEFINED VARIABLE errors on the in the mysqli statement that should be binding results to variables. Here is the code if you can help: //set connection variables $host = "localhost"; $username = "root"; $password = "password"; $db_name = "mydb"; //database name //connect to mysql server $mysqli = new mysqli($host, $username, $password, $db_name); //check if any connection error was encountered if(mysqli_connect_errno()) { echo "Error: Could not connect to database."; exit; } //Just counting ...required for pagination... $query = "SELECT COUNT(*) FROM t_persons"; $result = mysqli_query($mysqli,$query) or die(mysqli_connect_errno()); $num_rows = mysqli_fetch_row($result); $pages = new Paginator; $pages->items_total = $num_rows[0]; $pages->mid_range = 9; // Number of pages to display. Must be odd and > 3 $pages->paginate(); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } if ($stmt = $mysqli->prepare("SELECT p.PersonID, p.ImagePath, p.FamilyName, p.FirstName, p.OtherNames, p.Gender, p.CountryID, p.StatusID, i.IncidentDate, i.IncidentCountryID, i.AgencyID, i.KeywordID FROM t_incidents i INNER JOIN t_incident_persons ip ON ip.IncidentID = i.IncidentID INNER JOIN t_persons p ON ip.PersonID = p.PersonID WHERE p.PersonID>0" . $likes . " ORDER BY p.PersonID DESC $pages->limit")) { /* Execute the prepared Statement */ $stmt->execute(); /* Bind results to variables */ $stmt->bind_result($PersonID,$ImagePath,$FamilyName,$FirstName,$OtherNames,$Gender,$CountryID,$StatusID,$IncidentDate,$IncidentCountryID,$AgencyID,$KeywordID); /* fetch values */ while ($rows = $stmt->fetch()) { // display records in a table // $PersonID=$row[0]; ?> <div class="thumbnail"> <a href=details.php?PersonID=<?php echo $PersonID ?> target=gallery><img src="./Persons_Images/<?php echo $row[1]; ?>" width="100" height="130" alt="" /></a><br> <a href="details.php?PersonID=<?php echo $PersonID; ?>"> <?php echo $row[2]; ?> <?php echo $row[3]; ?></a> </div> <?php }?> <?php } /* Close the statement */ $stmt->close(); /* close our connection */ $mysqli->close(); ?>I will appreciate. Joseph Guys thanks for helping me solve the problem i had but now i have another problem and i am lost. i have included the code below for you to have overview.
This is the code:
<table style="width:100%; margin-left:auto; margin-right:auto"> so i want to call my php file with a query string to select a record out of a XML file... im close but cant get the variable i pass to be the record selected.. example... index.php?auction=1 i highlighted in red, where it doesnt pick up the proper row Code: [Select] <?php ini_set('display_errors', 1); error_reporting(E_ALL); $auction = $_GET{auction}; // parse the xml $xmlFileData = file_get_contents("items.xml"); $xmlData = new SimpleXMLElement($xmlFileData); [color=red]$location = $xmlData->item[$auction];[/color] //Retrieving the content from the selected item $title = $location->title; $value = $location->value; $itemnumber = $location->itemnumber; $description = $location->description; $donatedby = $location->donatedby; $image1 = $location->image1; $image2 = $location->image2; $image3 = $location->image3; $image4 = $location->image4; $image5 = $location->image5; $image6 = $location->image6; $image7 = $location->image7; $image8 = $location->image8; ?> <style> .itemimages img {width: 10px; height: 10px;} img.large {width: 100px; height: 100px;} </style> <script language="JavaScript" src="http://code.jquery.com/jquery-1.5.min.js" type="text/javascript"></script> <script> $().ready(function() { $(".itemimages img").click( $("#largepic").attr("src","this"); }); }); </script> <table border="1" cellpadding="10"> <tr> <td valign="top"> <img src="<?php echo $image1 ?>" alt="" border="0" class="large" id="largepic"><br> <div class="itemimages"> <?php // image 1 if (trim(''.$image1) != '') { echo "<img src='"; echo $image1; echo "' alt='' border='0'/> "; } // image 2 if (trim(''.$image2) != '') { echo "<img src='"; echo $image2; echo "' alt='' border='0'/> "; } // image 3 if (trim(''.$image3) != '') { echo "<img src='"; echo $image3; echo "' alt='' border='0'/> "; } // image 4 if (trim(''.$image4) != '') { echo "<img src='"; echo $image4; echo "' alt='' border='0'/> "; } // image 5 if (trim(''.$image5) != '') { echo "<img src='"; echo $image5; echo "' alt='' border='0'/> "; } // image 6 if (trim(''.$image6) != '') { echo "<img src='"; echo $image6; echo "' alt='' border='0'/> "; } // image 7 if (trim(''.$image7) != '') { echo "<img src='"; echo $image7; echo "' alt='' border='0'/> "; } // image 8 if (trim(''.$image8) != '') { echo "<img src='"; echo $image8; echo "' alt='' border='0'/> "; } ?> </div> </td> <td valign="top"> <?php echo $title ?><br> Estimated Value: <?php echo $value ?><br> Item Number: <?php echo $itemnumber ?><br><br> <?php echo $description ?><br><br> Donated by: <?php echo $donatedby ?><br> </td> </tr> </table> Hello everyone Just found this forum and really need some help. I'm trying to create a popup contact form for my product pages. I managed to get a php form from a random site and i cant get the form to pop up. http://www.e-sol.co.uk/printer-scanner-copier.php If someone could help i would be very grateful. I am trying to understand PHP OOP and I have some code that is not working. here is the error code. Code: [Select] Parse error: parse error, expecting `T_FUNCTION' in C:\wamp\www\testing\armor_lib.php on line 11 And here is the armor_lib.php file: <?php class armor { // Head public $head; public $torso; public $pants; public $gloves; public $boots; // new stuff here class head extends armor { function __construct($head){ $this->set_head($head); } } // Torso class torso extends armor { function __construct($torso){ $this->set_torso($torso); } } // Pants class pants extends armor { function __construct($pants){ $this->set_pants($pants); } } // Gloves class gloves extends armor { function __construct($gloves){ $this->set_gloves($gloves); } } // Boots class boots extends armor { function __construct($boots){ $this->set_boots($boots); } } } ?> And here is the php in the armor.php file I have: <?php $head = new armor("Leather Helm"); $torso = new armor("Leather Shirt"); $pants = new armor("Leather Pants"); $gloves = new armor("Chain Mail Gloves"); $boots = new armor("Leather Boots"); echo "You are wearing: " . $head->get_head() . "on your Head"; echo "<br />"; echo "You are wearing: " . $torso->get_torso() . "on your Torso"; echo "<br />"; echo "You are wearing: " . $pants->get_pants() . "on your Legs"; echo "<br />"; echo "You are wearing: " . $gloves->get_gloves() . "on your Hands"; echo "<br />"; echo "You are wearing: " . $boots->get_boots() . "on your Feet"; ?> Any Help in understanding this will be much appreciated. Thanks. Code: [Select] <?php require('config.php'); $sql = "SELECT m.Title as title , f.Reg_URL as reg FROM website_main as m JOIN website_front as f LIMIT 0,01 "; $result = @mysql_query($sql) or die(mysql_error()); echo "<table border='3'>"; echo "<font size='9'><tr> <th><FONT COLOR=red><center>Title</center></font></th> <th><FONT COLOR=red>reg</th> </tr></font>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table $reg = $row['reg']; echo "<tr><td bgcolor=''><center>"; echo $row['title']; echo "</td><td bgcolor=''><center>"; echo '.$reg.'; echo "</td></tr>"; } ?> I got a problem i try to use an attribute for $reg but only appears as .$reg. on website anyone know why? Parts i have problems with are $reg = $row['reg']; and echo '.$reg.';. thank you im making a website it works fine on firefox but on ie doesnt work correctly. page looks weird i see the error is <? include("index/index_files/front/php/include.php"); ?> anyone can help me its in a <html> tab. Hi there, I have a map of America made in flash, where you click on a state and the page should display the SQL database information for that state in the HTML table - but instead all it shows is the first entry of the database regardless of which state you click and it doesn't display the 2 radio buttons. My code is as follows Flash Actionscript 3 (just showing one state) Code: [Select] function waClick(event:MouseEvent):void { var waURL:URLRequest = new URLRequest("restaurants.php?state=Washington"); navigateToURL(waURL, "_self"); } wa_btn.addEventListener(MouseEvent.CLICK, waClick); PHP code Code: [Select] <?php include("mvfconnect.php"); $theChoice = $_GET['state']; $query = "SELECT * FROM restaurants WHERE" .$theChoice; $result = @ mysql_query($query); if (!$result) { $message="Unfortunately we are having problems with this page, we promise to have it fixed as soon as possible"; die($message); } $num = mysql_num_fields($result); $i=0; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $show1=substr($row['state'],0,50)."..."; $show2=substr($row['city'],0,50)."..."; $show3=substr($row['rname'],0,50)."..."; $show4=substr($row['address'],0,50)."..."; $show5=substr($row['pnum'],0,50)."..."; $show6=substr($row['web'],0,50)."..."; $show7=substr($row['dishes'],0,50)."..."; $show8=substr($row['dish_details'],0,50)."..."; $show9=substr($row['challenges'],0,50)."..."; $show10=substr($row['challenge_details'],0,50)."..."; $show11=substr($row['youtube'],0,50)."..."; $show12=substr($row['images'],0,50)."..."; echo "<tr>". "<td>".$row['city']."</td>". "<td>".$row['rname']."</td>". "<td>".$row['address']."</td>". "<td>".$row['pnum']."</td>". "<td>".$row['web']."</td>". "<td>".$row['dishes']."</td>". "<td>".$row['challenges']."</td>". "<td id='state".$i."' style='display:none'>".$row['state']."</td>". "<td id='city".$i."' style='display:none'>".$row['city']."</td>". "<td id='rname".$i."' style='display:none'>".$row['rname']."</td>". "<td id='address".$i."' style='display:none'>".$row['address']."</td>". "<td id='pnum".$i."' style='display:none'>".$row['pnum']."</td>". "<td id='web".$i."' style='display:none'>".$row['web']."</td>". "<td id='dishes".$i."' style='display:none'>".$row['dishes']."</td>". "<td id='dish_details".$i."' style='display:none'>".$row['dish_details']."</td>". "<td id='challenges".$i."' style='display:none'>".$row['challenges']."</td>". "<td id='challenge_details".$i."' style='display:none'>".$row['challenge_details']."</td>". "<td id='youtube".$i."' style='display:none'>".$row['youtube']."</td>". "<td id='images".$i."' style='display:none'>".$row['images']."</td>". "<td><input type='radio' name='vid' id='vid".$i."' onclick='openVideo(".$i.")' /></td>". "<td><input type='radio' name='pic' id='pic".$i."' onclick='openImage(".$i.")' /></td>". "<td class='last'style='display:none'>".$show1." ".$show2." ".$show3." ".$show4." ".$show5." ".$show6." ".$show7." ".$show8." ".$show9." ".$show10."</td>". "</tr>"; $i++; } ?> I have used this code before and it has worked fine, can someone please help me out! Hi I make 3 querys first Order by DESC, second RAND() and third ASC. Now I want that in the second query can't be the same ids (produgg_users.id) that already taken in the first. And in the third not the ids from first and second. Like I have it now the same users can show up in the RAND() and the ASC like in DESC. Here my Script so far: $rs = mysql_query("select produgg_users.id, twitterUser, credits from produgg_users where twitterUser != '' and produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY credits DESC LIMIT 10") or die(mysql_error()); $nr = @mysql_num_rows($rs); if($nr != 0) { print "<p>Simply click <strong>get 1 point</strong> and you will automatically FOLLOW the USER and earn the credit!</p>"; print "<p><font color=\"#0066FF\">Top Members</font></p>"; while($row=@mysql_fetch_object($rs)) { $divLeft = '<div id="thediv_'.$row->id.'"><div style="float:left;width:400px;">'; $divRight = '<div style="float:left;width:150px;">'; $clearDiv = '<div style="clear:both;"></div>'; print "$divLeft<img src=\"http://api.twitter.com/1/users/profile_image/".strip_tags($row->twitterUser)."?size=mini\" alt=\"\" /> ".strip_tags($row->twitterUser)." <font color=\"#999999\" size=\"1\">$row->credits Points</font></div>$divRight <a href='javascript:void(0);' id='vote_$row->id' class='getPoint'>Get 1 Point</a></div>$clearDiv<hr /></div>"; $z = 1; } } //Lucky Riders $rs = mysql_query("select produgg_users.id, twitterUser, credits from produgg_users where twitterUser != '' and produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY RAND() LIMIT 5") or die(mysql_error()); $nr = @mysql_num_rows($rs); if($nr != 0) { print "<p><font color=\"#0066FF\">Lucky Riders</font></p>"; while($row=@mysql_fetch_object($rs)) { $divLeft = '<div id="thediv_'.$row->id.'"><div style="float:left;width:400px;">'; $divRight = '<div style="float:left;width:150px;">'; $clearDiv = '<div style="clear:both;"></div>'; print "$divLeft<img src=\"http://api.twitter.com/1/users/profile_image/".strip_tags($row->twitterUser)."?size=mini\" alt=\"\" /> ".strip_tags($row->twitterUser)." <font color=\"#999999\" size=\"1\">$row->credits Points</font></div>$divRight <a href='javascript:void(0);' id='vote_$row->id' class='getPoint'>Get 1 Point</a></div>$clearDiv<hr /></div>"; $z = 1; } } //Lucky Riders $rs = mysql_query("select produgg_users.id, twitterUser, credits from produgg_users where twitterUser != '' and produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY credits ASC LIMIT 5") or die(mysql_error()); $nr = @mysql_num_rows($rs); if($nr != 0) { print "<p><font color=\"#0066FF\">Last Rides</font></p>"; while($row=@mysql_fetch_object($rs)) { $divLeft = '<div id="thediv_'.$row->id.'"><div style="float:left;width:400px;">'; $divRight = '<div style="float:left;width:150px;">'; $clearDiv = '<div style="clear:both;"></div>'; print "$divLeft<img src=\"http://api.twitter.com/1/users/profile_image/".strip_tags($row->twitterUser)."?size=mini\" alt=\"\" /> ".strip_tags($row->twitterUser)." <font color=\"#999999\" size=\"1\">$row->credits Points</font></div>$divRight <a href='javascript:void(0);' id='vote_$row->id' class='getPoint'>Get 1 Point</a></div>$clearDiv<hr /></div>"; $z = 1; } } I have a simple text file called bio.txt: Code: [Select] wohlersr; Richie Wohlers; Intermediate; Four Aces meyersg; Greg Meyers; Novice; Four Aces I wrote a little script, to return the info for Greg Meyers if the user id is correct, or say "Member not found" if incorrect. For some reason, my output is giving me both. I assume it's a context error, but can't figure it out. Here's my script: Code: [Select] <?php $file=file("bio.txt"); $count=count($file); $i=0; while($i<=$count) { $row = explode(";", $file[$i]); $id = $row[0]; $name = $row[1]; $class = $row[2]; $club = $row[3]; if($id=="meyersg"){ echo $name."</br>"; echo $class."</br>"; echo $club."</br>"; }else{ echo "Member not found."; } $i++; } ?> And here's the output I'm getting: Code: [Select] Member not found. Greg Meyers Novice Four Aces Member not found. i'm getting this erro "Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /***/***/*****.php on line 278 not an active session, starts new" this is the code: if ($phase = mysql_result(mysql_query("SELECT `phase` FROM `as_support` WHERE `mission` = '$var2'"),0,0)) { if ($phase=='5') { // mysql_query("DELETE FROM `as_support` WHERE `mission` = '$var2'"); // header("Location: https://www.**********/*******/*******.php"); } else { echo date('h:i:s') . ": PHASE is $phase<br />"; echo "\$var1=$var1,\$var2=$var2<br />"; } } else { echo "not an active session, starts new<br />"; echo "\$var1=$var1,\$var2=$var2<br />"; mysql_query("INSERT INTO `as_support` (`mission`, `phase`) VALUES ('$var2', '0')") OR DIE(mysql_error()); the first line is line no. 278 can someone please tell me what to do? tnx shirley Hi. I am from poland. I am 17 old age and like webmastering. I write my social network. I have new server 10 GB VPS and my script no runing In my server. in my server do can not login. No runing function Code: [Select] mb_strtolower();as delete function mb_strtolower() ; this login runing. In my server haven`t installing liberary GD and no runing upload avatars. my code upload is: elseif ($_GET['act'] == "upload") { echo <<< KONIEC <hr> <center> <p> <h2>Dodaj zdjęcie</h2> <ul class="gallery clearfix"> <li class="extra"> KONIEC; error_reporting(E_ALL); // we first include the upload class, as we will need it here to deal with the uploaded file include('include/class.upload.php'); // retrieve eventual CLI parameters $cli = (isset($argc) && $argc > 1); if ($cli) { if (isset($argv[1])) $_GET['file'] = $argv[1]; if (isset($argv[2])) $_GET['dir'] = $argv[2]; if (isset($argv[3])) $_GET['pics'] = $argv[3]; } // set variables $dir_dest = (isset($_GET['dir']) ? $_GET['dir'] : 'test'); $dir_pics = (isset($_GET['pics']) ? $_GET['pics'] : $dir_dest); if (!$cli) { } // we have three forms on the test page, so we redirect accordingly if ((isset($_POST['action']) ? $_POST['action'] : (isset($_GET['action']) ? $_GET['action'] : '')) == 'simple') { // ---------- SIMPLE UPLOAD ---------- // we create an instance of the class, giving as argument the PHP object // corresponding to the file field from the form // All the uploads are accessible from the PHP object $_FILES $handle = new Upload($_FILES['my_field']); // then we check if the file has been uploaded properly // in its *temporary* location in the server (often, it is /tmp) if ($handle->uploaded) { // yes, the file is on the server // now, we start the upload 'process'. That is, to copy the uploaded file // from its temporary location to the wanted location // It could be something like $handle->Process('/home/www/my_uploads/'); $handle->Process($dir_dest); function TestProcess(&$handle, $title = 'test', $details='') { global $dir_pics, $dir_dest; $unlink = 'test/'. $handle->file_dst_name; $myid = $_SESSION['id']; $opis = htmlspecialchars(stripslashes(strip_tags(trim($_POST["opis"]))), ENT_QUOTES); $handle->Process($dir_dest); if ($handle->processed) { unlink("$unlink"); $link = ''.$dir_pics.'/' . $handle->file_dst_name .''; $addphoto = mysql_query("INSERT INTO photo VALUES('', '$myid', '$link', '$opis')"); echo <<< KONIEC <br> <center> <img src="$link" > <br> <br /> </center> KONIEC; } else { echo '<fieldset class="classuploadphp">'; echo ' <legend>' . $title . '</legend>'; echo ' Error: ' . $handle->error . ''; if ($details) echo ' <pre class="code php">' . htmlentities($details) . '</pre>'; echo '</fieldset>'; } } if (!file_exists($dir_dest)) mkdir($dir_dest); // ----------- $handle->image_convert = 'jpg'; $handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_x = 500; $handle->image_precrop = 15; $handle->image_watermark = "watermark_large.png"; $handle->image_watermark_x = 20; $handle->image_watermark_y = -20; TestProcess($handle, '15px pre-cropping (before resizing 800 wide), large watermark automatically reduced, position 20 -20', "\$foo->image_convert = 'jpg';\n\$foo->image_resize = true;\n\$foo->image_ratio_y = true;\n\$foo->image_x = 800;\n\$foo->image_precrop = 15;\n\$foo->image_watermark = 'watermark_large.png';\n\$foo->image_watermark_x = 20;\n\$foo->image_watermark_y = -20;"); } else { // one error occured echo '<fieldset>'; echo ' <legend>file not uploaded to the wanted location</legend>'; echo ' Error: ' . $handle->error . ''; echo '</fieldset>'; } // we copy the file a second time // we delete the temporary files $handle-> Clean(); } else { // if we are here, the local file failed for some reasons echo '<fieldset>'; echo ' <legend>local file error</legend>'; echo ' Error: ' . $handle->error . ''; echo '</fieldset>'; } echo <<< KONIEC <li> </ul> </p> </center> KONIEC; is it the only problem that isn`t installing GD as i have something off in php.ini ? Plise Help me I Have An error on line 42 not sure what it is can any one tell? $foundnum = mysql_num_rows($run); Elo, I'm creating a very simple image list that is function generated which pulls the source from a table in my database, this is my code Code: [Select] $output = "<ul>"; $img_src = get_all_image_src($sel_event['id']); while($src = mysql_fetch_array($img_src)) { for($i=0;$i <= 9; $i++) { $output .= "<li>"; $output .= "<a"; $output .= " class ='album'"; $output .= " rel='group'"; $output .= " href='/images/gallery/'" . $src['img_src'] . $i; $output .= ".jpg"; $output .= " title='sample 1'"; $output .= ">"; //Image Thumb $output .= "<img"; $output .= " src='/images/gallery/'"; $output .= $src['img_thumb_src']. $i . ".jpg"; $output .= "alt='image01' "; $output .= "title='sample title' />"; $output .= "tae"; $output .= "</a>"; $output .= "</li>"; } } $output .= "</ul>"; return $output; and the img src doesnt seems to add up... my folder structure is Sandbox>image>gallery>2011>Mall>Event>Thumbs where Sandbox is the main directory. i tried echoing the $src['img_src'] and it displays correctly the data to be added (which is 2011/Mall/Event/ plus $i and a .jpg) .. sorry noob here... any thoughts? am i missing a simple detail? I am trying to use the following code snippet to return values from a database with a "," after each value apart form the last one. At the moment for testing I have 2 rows with values 1 and 3 $totalRows_Recordset3 equals 2 (I echoed this to check) $i=1; while($row_Recordset3 = mysql_fetch_assoc($Recordset3)) { if($i < $totalRows_Recordset3) { $str = $str.$row_Recordset3['reading'].","; $i=$i+1; } else { $str = $str.$row_Recordset3['reading']; $i=$i+1; } } I get the number 3 which is the last value in the database, but I can't see why I don't get "1,3" I am sure it is something simple but it just escapes me. Thanks in advance for any help Gordon Hi, I am trying to write in an existing excel file. But for some reason, I can't open the workbook (but I know I have made similar code work before). Here I am just pasting the code upto the error line $filename="C:\\apache\\htdocs\\GAC2\\dload\\template.xls"; $excel = new COM("excel.application") or die("Unable to instanciate excel"); $excel->Visible = 1; $excel->DisplayAlerts = 1; try{ $wkb = $excel->Workbooks->Open($filename); }catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } //........ Later part of the code This returns the following error Code: [Select] Caught exception: Source: Microsoft Office Excel Description: Unable to get the Open property of the Workbooks class For record, the I have already validated the file location. And I have tried the following line instead without any positive result. Code: [Select] $filename="C:\apache\htdocs\GAC2\dload\template.xls"; Looking for any help please. -Abd Okey so i made a table that you put your name,author,and message when you submit it , it echoes a table with the name,author and message written (and it also echoes a delete buttom,so delete this post oif necessary) im new to php and i have been with this problem for a couple of weeks so i guess its time to ask for some help the problem is that i dunnot know how to make my delete buttom work! i tried if statement but it dosent work i also tried ternary operation and dint work :S i read that there is something like $post[ID](and this is supposed to get the ID of the post submmited, and delete it) im not sure, im so confused! help! XD this is the code <?php $tittle=$_POST['tittle']; $author=$_POST['author']; $message=$_POST['message']; if ($_POST['submitnews']){ $currentdate= date("y-m-d"); $currenttime=date("H:i:s",strtotime("-6 hours")); $post=mysql_query("INSERT INTO news VALUES('','$tittle','$author','$message','$currentdate','$currenttime')"); echo"Posted!"; } $select=mysql_query("SELECT * FROM news ORDER BY id DESC"); while ($row= mysql_fetch_assoc($select)) { $id=$row['id']; $tittle=$row['tittle']; $author=$row['author']; $message=$row['message']; $date=$row['date']; $time=$row['time']; if ($_SESSION['admin']) { echo " <table width='488px' id='news_table'> <tr> <td> </td> <td> <center><font size='5'>$tittle</font></center><br> </td> </tr> <tr> <td> </td> <td> $message </td> </tr> <tr> <td> </td> <td> <font size='1'>Posted By:<font color='green'>$author</font> on <font color='gray'>$date</font> at <font color='gray'>$time</font></font> <input name='delete' type='submit' value='delete'> <td> </td> </tr><br><br> </table>"; Hi guys, I'm working on a side-project whilst my work at Uni is at a low but I'm extremely rusty on PHP; I've not touched it since around '07. Before I get on to my project, which will lift information from external websites, I'm just trying to acquaint myself with cURL again. Before I get flamed, yes this code is largely lifted from a website, but I pretty much understand it. My aim is to be able to get the title of a website, namely Facebook. Whilst this code is fine on seemingly any other website, it doesn't seem to be able to work for Facebook. I've checked the source code, and I really can't see the problem. Can anyone shed some light for me? Code: [Select] <?php $url = 'http://www.facebook.com/'; $webinfo = get_data($url); $title = get_match('/<title>(.*)<\/title>',$webinfo); $content= '<h2>Title of webpage: </h2><p>'.$name.'</p>'; echo $content; function get_match($regex,$content) { preg_match($regex,$content,$matches); return $matches[1]; } //gets the data from a URL function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch); curl_close($ch); return $data; } ?> Thanks!!! Im trying to parse this string and put it in the array.. However i dont know how.. Code: [Select] 11111<>your mobile<>the receiver<>keyword<>2012-01-15<>12:09:08<>wow "this", is great! I want to remove this sign <> and put the elements on the array.. Also i would not want to loose the quotes and commas Can someone help me? thanks |