probleme passage php4 a php5

patweb
Invité n'ayant pas de compte PHPfrance

28 juil. 2009, 22:32

bonjour, j ai un probleme pour le passage d un code en php 5

quand je remplace <? par <?php cela me met un message d erreur pour la fonction

<?=$bannerselect;?> qui fontionnait tres bien en php 4

et que si je la modifie en <?php=$bannerselect;?> me met un message parse error

voici le code de la page index

Code : Tout sélectionner

<?php include("header.inc"); $dropdown = "#2c64ea"; $dropdowntext = "#ffffff"; function strtotitle($strtochange){ $strtochange = strtolower($strtochange); $string_array = explode(" ",$strtochange); $fixed_str = ""; foreach ($string_array as $part){ $fixed_str .= strtoupper(substr("$part",0,1)); $fixed_str .= substr("$part",1,strlen($part)); $fixed_str .= " "; } return rtrim($fixed_str); } function color($clr){ echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" summary=\"color\">\n<tr>"; $colors = "000000,000033,000066,000099,0000CC,0000FF,003300,003333,003366,003399,0033CC,0033FF,006600,006633,006666,006699,0066CC,0066FF,009900,009933,009966,009999,0099CC,0099FF,00CC00,00CC33,00CC66,00CC99,00CCCC,00CCFF,00FF00,00FF33,00FF66,00FF99,00FFCC,00FFFF,330000,330033,330066,330099,3300CC,3300FF,333300,333333,333366,333399,3333CC,3333FF,336600,336633,336666,336699,3366CC,3366FF,339900,339933,339966,339999,3399CC,3399FF,33CC00,33CC33,33CC66,33CC99,33CCCC,33CCFF,33FF00,33FF33,33FF66,33FF99,33FFCC,33FFFF,660000,660033,660066,660099,6600CC,6600FF,663300,663333,663366,663399,6633CC,6633FF,666600,666633,666666,666699,6666CC,6666FF,669900,669933,669966,669999,6699CC,6699FF,66CC00,66CC33,66CC66,66CC99,66CCCC,66CCFF,66FF00,66FF33,66FF66,66FF99,66FFCC,66FFFF,990000,990033,990066,990099,9900CC,9900FF,993300,993333,993366,993399,9933CC,9933FF,996600,996633,996666,996699,9966CC,9966FF,999900,999933,999966,999999,9999CC,9999FF,99CC00,99CC33,99CC66,99CC99,99CCCC,99CCFF,99FF00,99FF33,99FF66,99FF99,99FFCC,99FFFF,CC0000,CC0033,CC0066,CC0099,CC00CC,CC00FF,CC3300,CC3333,CC3366,CC3399,CC33CC,CC33FF,CC6600,CC6633,CC6666,CC6699,CC66CC,CC66FF,CC9900,CC9933,CC9966,CC9999,CC99CC,CC99FF,CCCC00,CCCC33,CCCC66,CCCC99,CCCCCC,CCCCFF,CCFF00,CCFF33,CCFF66,CCFF99,CCFFCC,CCFFFF,FF0000,FF0033,FF0066,FF0099,FF00CC,FF00FF,FF3300,FF3333,FF3366,FF3399,FF33CC,FF33FF,FF6600,FF6633,FF6666,FF6699,FF66CC,FF66FF,FF9900,FF9933,FF9966,FF9999,FF99CC,FF99FF,FFCC00,FFCC33,FFCC66,FFCC99,FFCCCC,FFCCFF,FFFF00,FFFF33,FFFF66,FFFF99,FFFFCC,FFFFFF"; $array = explode(",",$colors); $rows = count($array)/6; $i = 0; foreach ($array as $value) { echo "<td bgcolor=\"#" . $value . "\"><img alt=\"\" border=\"0\" src=\"clear.gif\" width=\"6\" height=\"6\" onclick=\"color" . $clr . "('#" . $value . "');\" /></td>\n"; ++$i; if($i == $rows) { echo "</tr>\n<tr>"; $i = 0; } } echo "</tr>\n</table>"; } $bannerselect = "<select name=\"select_banner\" onChange=\"showimage()\" size=\"0\" style=\"background-color: $dropdown; color: $dropdowntext; font-weight: bold; font-size: 8pt;\">\n"; $bannerselect .= "<option value=\"arrow.png\">Select Banner</option>\n"; $open = opendir("banner"); while ($files = readdir($open)) { $filename = $files; $name = str_replace(".png", "", $filename); $name = str_replace("_", " ", $name); $name = str_replace("01", "1", $name); $name = str_replace("02", "2", $name); $name = str_replace("03", "3", $name); $name = str_replace("04", "4", $name); $name = str_replace("05", "5", $name); $name = str_replace("06", "6", $name); $name = str_replace("07", "7", $name); $name = str_replace("08", "8", $name); $name = str_replace("09", "9", $name); $name = strtotitle($name); if ($filename == "."){ $bannerselect .= ""; } elseif ($filename == ".."){ $bannerselect .= ""; } elseif ($filename == "Thumbs.db"){ $bannerselect .= ""; } else { $bannerselect .= "<option value=\"$filename\">$name</option>\n"; } } $bannerselect .= "</select>\n"; ?> <script language="javascript" type="text/javascript"> <!-- var win=null; function NewWindow(mypage,myname,w,h,scroll,pos){ if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;} if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;} else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20} settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no'; win=window.open(mypage,myname,settings);} function showimage() { if (!document.images) return document.images.banner.src= 'banner/' + document.fastbanner.select_banner.options[document.fastbanner.select_banner.selectedIndex].value } function color1(clr1){ document.fastbanner.titlecolor.value=clr1; } function color2(clr2){ document.fastbanner.tagcolor.value=clr2; } function bannerpopup(myform, windowname) { if (! window.focus)return true; window.open('', windowname, 'top=100,left=200,height=75,width=500,location=no,resizable=no,scrollbars=no,status=no'); myform.target=windowname; return true; } // layers //--> </script> <div align="center"> <table summary="table" cellspacing="0" cellpadding="1" border="0" width="100%" align="center"> <tr> <td class="border"> <table summary="table" border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td colspan="1" class="header"> <table width="100%" cellspacing="0" cellpadding= "0" summary="table"> <tr> <td class="header">  <a onclick= "NewWindow(this.href,'instructions','500','300','yes','center');return false" onfocus="this.blur()" href= "instructions.html" style="color: #ffffff;">Instructions</a> </td> <td align="right"> <a onclick= "NewWindow(this.href,'fonts','325','325','yes','center');return false" onfocus="this.blur()" href= "fonts.php" style="color: #ffffff;">Fonts</a>  </td> </tr> </table> </td> </tr> <tr> <td class="main" colspan="4" style="padding: 3px 3px 3px 3px;"> <p> One of the basic advertising tools developed for the Web is the banner advertisement. Use this powerful new tool to enhance your site, and draw traffic with easy to make eye catching ads and banners. </p> </td> </tr> </table> </td> </tr> </table> <br /> <form action="banner.php" name="fastbanner" method="post" onsubmit="bannerpopup(this,'Banner')"> <TABLE summary="table" cellspacing="0" cellpadding="1" border="0" width="100%" align="center"> <TR> <TD class="border"> <TABLE summary="table" border="0" cellspacing="0" cellpadding="0" width="100%"> <TR> <TD colspan="5" class="header"> <table width="100%" cellspacing="0" cellpadding="0" summary="table"> <tr> <td class="header">&nbsp;<img src="arrow.gif" width="10" height="10" border="0" alt=" ">&nbsp;Select Your Banner.</td> <td align="right"> <?=$bannerselect;?> </td> </tr> </table> </TD> </TR> <TR> <TD class="main" colspan="5" align="center"> <table cellspacing="0" cellpadding="0" width="484" summary="Banner Table"> <tr> <td rowspan="2"><img src="Yscala1.gif" width="16" height="79" border="0" alt=" " /></td> <td><img src="Xscala1.gif" width="468" height="15" border="0" alt=" " /></td> </tr> <tr> <td valign="bottom"><img ismap onclick="alert('Coordinates:\n\nX POS: '+self.event.offsetX+'\nY POS: '+self.event.offsetY);" name="banner" src="banner/arrow.png" width="468" height="60" /></td> </tr> </table> </TD> </TR> </TABLE> </TD> </TR> </TABLE><br> <TABLE summary="table" cellspacing="0" cellpadding="1" border="0" width="100%" align="center"> <TR> <TD class="border"> <TABLE summary="table" border="0" cellspacing="0" cellpadding="0" width="100%"> <TR> <TD colspan="1" class="header"> <table width="100%" cellspacing="0" cellpadding="0" summary="table"> <tr> <td class="header">&nbsp;<img src="arrow.gif" width="10" height="10" border="0" alt=" ">&nbsp;Pick your title text.</td> <td align="right"><select name="titlef" size="0" style="background-color: <?=$dropdown?>; color: <?=$dropdowntext?>; font-weight: bold; font-size: 8pt;"> <option value="abadi.ttf">Select Font</option> <?php $open = opendir("fonts"); while ($files = readdir($open)) { $filename = $files; $name = str_replace(".ttf", "", $filename); $name = strtotitle($name); if ($filename == "."){ print "\n"; } elseif ($filename == ".."){ print "\n"; } else { print "<option value=\"$filename\">$name</option>\n"; } } ?> </select><img src="pixel.gif" width="1" height="1" border="0" alt=" " /><select name="titlesize" size="0" style="background-color: <?=$dropdown?>; color: <?=$dropdowntext?>; font-weight: bold; font-size: 8pt;"> <option value="15">Size</option> <?php $i = 5; while ($i <= 30) { print("<option value=\"$i\">$i</option>"); $i++; } ?> </select></td> </tr> </table> </TD> </TR> <TR> <TD class="main" colspan="4"> <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td width="60%"><input name="titletext" value="YourSite" size="38" maxsize="80"></td> <td width="40%"><INPUT type="text" size="7" name="titlecolor" maxlength="7" value="#000000"> <input type="checkbox" name="titleshadow" value="yes" style="border:0px;"> Shadow?</td> </tr> <tr> <td align="left" valign="top"> <?php color(1); ?> </td> <td><input name="titlex" type="text" value="54" size="3" maxsize="3"> X Coordinates<br> <input name="titley" type="text" value="20" size="3" maxsize="2"> Y Coordinates</td> </tr> </table> </TD> </TR> </TABLE> </TD> </TR> </TABLE><br> <TABLE summary="table" cellspacing="0" cellpadding="1" border="0" width="100%" align="center"> <TR> <TD class="border"> <TABLE summary="table" border="0" cellspacing="0" cellpadding="0" width="100%"> <TR> <TD colspan="1" class="header"> <table width="100%" cellspacing="0" cellpadding="0" summary="table"> <tr> <td class="header">&nbsp;<img src="arrow.gif" width="10" height="10" border="0" alt=" ">&nbsp;Pick your tag text.</td> <td align="right"><select name="tagf" size="0" style="background-color: <?=$dropdown?>; color: <?=$dropdowntext?>; font-weight: bold; font-size: 8pt;"> <option value="abadi.ttf">Select Font</option> <?php $open = opendir("fonts"); while ($files = readdir($open)) { $filename = $files; $name = str_replace(".ttf", "", $filename); $name = strtotitle($name); if ($filename == "."){ print "\n"; } elseif ($filename == ".."){ print "\n"; } else { print "<option value=\"$filename\">$name</option>\n"; } } ?> </select><img src="pixel.gif" width="1" height="1" border="0" alt=" " /><select name="tagsize" size="0" style="background-color: <?=$dropdown?>; color: <?=$dropdowntext?>; font-weight: bold; font-size: 8pt;"> <option value="15">Size</option> <?php $i = 5; while ($i <= 30) { print("<option value=\"$i\">$i</option>"); $i++; } ?> </select></td> </tr> </table> </TD> </TR> <TR> <TD class="main" colspan="4"> <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td width="60%"><input name="tagtext" value="This is my tagline." size="38" maxsize="80"></td> <td width="40%"><INPUT type="text" size="7" name="tagcolor" maxlength="7" value="#000000"> <input type="checkbox" name="tagshadow" value="yes" style="border:0px;"> Shadow?</td> </tr> <tr> <td align="left" valign="top"> <?php color(2); ?> </td> <td><input name="tagx" type="text" value="54" size="3" maxsize="3"> X Coordinates<br> <input name="tagy" type="text" value="55" size="3" maxsize="2"> Y Coordinates</td> </tr> </table> </TD> </TR> </TABLE> </TD> </TR> </TABLE> <input type="submit" value="Create"> <input type="reset" value="Reset"> </form> <br />Powered by <a href="http://fastbanner.templatesforall.com" target="_BLANK">FastBanner</a> 4 RC 2.<br /> <?php include("gencount.txt"); echo " banner"; $filename = "gencount.txt"; $fp = fopen($filename, "r"); $count = fread($fp, 26); fclose($fp); if ($count > 1) { echo "s"; } elseif ($count == 0) { echo "s"; } ?> generated since install. </div> <?php include("footer.inc"); ?>

si quelqu un voit comment resoudre le probleme

pour voir le prog en ligne http://www.marocvisite.com/creaban/

merci

Mammouth du PHP | 2937 Messages

28 juil. 2009, 22:37

Il n'est jamais trop tard pour apprendre de bonnes pratiques de codage en PHP. ;)

Il ne faut plus écrire
<?=$bannerselect;?>
mais
<?php echo $bannerselect; ?>

patweb
Invité n'ayant pas de compte PHPfrance

28 juil. 2009, 23:49

merci pour cette reponse rapide,

cela a resolu une partie de mon probleme mais le code ne fonctionne toujours pas

j ai un probleme sur l affichage de l image de la police (font)qui comme elle ne s affiche pas dans la fenetre de visualisation n est pas reconnu pour la creation de la banniere.

je pense que la aussi il doit rester un bout de code pas compatible php5

voila le code concernant le traitement de la police



Code : Tout sélectionner

<option value="abadi.ttf">Select Font</option> <?php $open = opendir("fonts"); while ($files = readdir($open)) { $filename = $files; $name = str_replace(".ttf", "", $filename); $name = strtotitle($name); if ($filename == "."){ print "\n"; } elseif ($filename == ".."){ print "\n"; } else { print "<option value=\"$filename\">$name</option>\n"; } } ?>
merci