bonanzab Posted October 24, 2009 Share Posted October 24, 2009 Hi everyone It's been days trying to get this code to work with microweb server. The script works fine on my website, when I try it on microweb (a local server) it works with a minor error. For some unknown reason the leaf image does not show, it skips this code echo '<td width="17%" height="7" bgcolor="#009900" align="center">'; if (file_exists($partpath5)){ echo '<img width="120" height="120" and goes to thise code. Can someone please help me, I'm going nuts. }else{ echo '<img width="120" height="120" src="'.$imgpath5.'N/NPA.jpg">'; <?PHP function alert($alert) { $out .='<script type="text/javascript"> alert("'.$alert.'"); </script> '; print $out; } function find($name, $view){ global $link; switch($view){ case '1': $column = 'Bloom_Name'; break; case '2': $column = 'Pod_Name'; break; case '3': $column = 'Pollen_Name'; break; case '4': $column = 'Hybridiser'; break; case '5': $column = 'Origin'; break; case '6': $column = 'appove'; break; case '7': $column = 'Leaf_Image'; break; default: $column = 'Bloom_Name'; break; } $connection = mysql_connect("localhost","root","")or die(mysql_error()); $db_select =mysql_select_db('internb7', $connection) or die ("Couldn't select database."); $SQL = "SELECT Bloom_Name, Pod_Name, Pollen_Name, Hybridiser, Origin, approve, Leaf_Image " . "FROM ihsreg " . "WHERE " . $column . " LIKE '" . $name . "' AND $column != '' " . "ORDER BY Bloom_Name ASC"; $result = mysql_query($SQL); $num=mysql_num_rows($result); $results = array(); while($row = mysql_fetch_row($result)){ $results[] = $row; } return $results; } $noimagemessage = "No Photo Available"; if(isset($_GET['search'])){ $search = urldecode(urldecode($_GET['search'])); $y = 0; $results[0]=Array(); $results[1]=Array(); $results[2]=Array(); $results[3]=Array(); $results[4]=Array(); $results[5]=Array(); $results[6]=Array(); $results = find($search,$_GET['view']); $y = sizeof($results); } ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> img{ border:0; } </style> <script type="text/javascript"> function open_win(img){ window.open("cvdata1.php?search="+img); } </script> </head> <body bgcolor="#FFFFFF" BACKGROUND="http://localhost/cvimages/b2a.jpg"><body> <div align="center"><img src="http://localhost/SEimages/CVtittle.gif" width="320" height="65"> <br> <b><font face="Trebuchet MS">Click On Image For Details</font></b><br> <table border=2 width="100%" bordercolor="#006666" cellpadding="1" cellspacing="1" bordercolorlight="#999900" bordercolordark="#CCCC00"> <?PHP for($x=0; $x<count(@$results); $x++){ echo '<tr>'; echo '<th width="17%" height="7" align="center" bgcolor="#CCFFCC"><font color="#000000" face="Trebuchet MS">Cultivar</font></th>'; echo '<th width="16%" height="7" align="center" bgcolor="#339999"><font color="#000000" face="Trebuchet MS">Pod Parent</font></th>'; echo '<th width="17%" height="7" align="center" bgcolor="#99CCCC"><font color="#000000" face="Trebuchet MS">Pollen Parent</font></th>'; echo '<th width="17%" height="7" align="center" bgcolor="#CCCC99"><font color="#000000" face="Trebuchet MS">Hybridizer</font></th>'; echo '<th width="16%" height="7" align="center" bgcolor="#CCCC33"><font color="#000000" face="Trebuchet MS">Origin</font></th>'; echo '<th width="17%" height="7" align="center" bgcolor="#009900"><font color="#000000" face="Trebuchet MS">Leaf</font></th>'; echo '</tr>'; echo '<tr>'; $pathroot="http://localhost/"; $imgpath=$pathroot.""; $imgpath3=$pathroot."Hybridizer/"; $imgpath4=$pathroot."Origin/"; $imgpath5=$pathroot."Leaf/"; $img0=ucwords(trim($results[$x][0])); $img1=ucwords(trim($results[$x][1])); $img2=ucwords(trim($results[$x][2])); $img3=ucwords(trim($results[$x][3])); $img4=ucwords(trim($results[$x][4])); $img5=ucwords(trim($results[$x][5])); $img_1=ucwords(trim($results[$x][1])); $img_2=ucwords(trim($results[$x][2])); $img_3=ucwords(trim($results[$x][3])); $img_4=ucwords(trim($results[$x][4])); $img_5=ucwords(trim($results[$x][5])); $img_5=substr($img5,0,-4); $appr=strtoupper(trim($results[$x][0])); $subpath0=substr($img0,0,1)."/"; $subpath1=substr($img1,0,1)."/"; $subpath2=substr($img2,0,1)."/"; $subpath3=substr($img3,0,1)."/"; $subpath4=substr($img4,0,1)."/"; $subpath5=substr($img5,0,1)."/"; $partpath0=$subpath0.$img0.".jpg"; $partpath1=$subpath1.$img1.".jpg"; $partpath2=$subpath2.$img2.".jpg"; $partpath3="Hybridizer/".$subpath3.$img3.".jpe"; $partpath4="Origin/".$subpath4.$img4.".jpe"; $partpath5="Leaf/".$subpath5.$img5; $fullpath0=$imgpath.$partpath0; $fullpath1=$imgpath.$partpath1; $fullpath2=$imgpath.$partpath2; $fullpath3=$imgpath.$partpath3; $fullpath4=$imgpath.$partpath4; $fullpath5=$imgpath.$partpath5; echo '<td width="17%" height="7" bgcolor="#CCFFCC" align="center">'; if (trim($appr) == "True" || trim($appr)=="TRUE") { if (file_exists($partpath0)){ echo '<a href="cvdata1.php?search='.$img0.'"'.'target="_blank"><img width="120" height="120" src="'.$fullpath0.'"></a>'; }else{ echo '<img width="120" height="120" src="'.$imgpath.'N/NBA.jpe">'; } } else { echo '<img width="120" height="120" src="'.$imgpath.'B/BRP.jpe">'; } echo '<br><font color="#000000" face="Trebuchet MS"><b>'.$img0."</b></font></td>"; /* No 1 Pod */ echo '<td width="16%" height="7" bgcolor="#339999" align="center">'; if (file_exists($partpath1)){ if ($img1=="Unknown"){ echo '<img width="120" height="120" src="'.$fullpath1.'">'; }else{ echo '<a href="cvdata1.php?search='.$img1.'"'.'target="_blank"><img width="120" height="120" src="'.$fullpath1.'"></a>'; } }else{ echo '<img width="120" height="120" src="'.$imgpath.'N/NBA.jpe">'; } echo '<br><font color="#000000" face="Trebuchet MS"><b>'.$img_1."</b></font></td>"; /* No 2 Pollen */ echo '<td width="17%" height="7" bgcolor="#99CCCC" align="center">'; if (file_exists($partpath2)){ if ($img2=="Unknown"){ echo '<img width="120" height="120" src="'.$fullpath2.'">'; }else{ echo '<a href="cvdata1.php?search='.$img2.'"'.'target="_blank"><img width="120" height="120" src="'.$fullpath2.'"></a>'; } }else{ echo '<img width="120" height="120" src="'.$imgpath.'N/NBA.jpe">'; } echo '<br><font color="#000000" face="Trebuchet MS"><b>'.$img_2."</b></font></td>"; /* No 3 Hybridiser */ echo '<td width="17%" height="7" bgcolor="#CCCC99" align="center">'; if (file_exists($partpath3)){ if ($img3=="Unknown"){ echo '<img width="120" height="120" src="'.$fullpath3.'">'; }else{ echo '<a href="cvdata1.php?search='.$img3.'"'.'target="_blank"><img width="120" height="120" src="'.$fullpath3.'"></a>'; } }else{ echo '<img width="120" height="120" src="'.$imgpath3.'H/HNP.jpe">'; } echo '<br><font color="#000000" face="Trebuchet MS"><b>'.$img3."</b></font></td>"; /* No 4 Origin */ echo '<td width="16%" height="7" bgcolor="#CCCC33" align="center">'; if (file_exists($partpath4)){ if ($img4=="Unknown"){ echo '<img width="120" height="120" src="'.$fullpath4.'">'; }else{ echo '<a href="cvdata1.php?search='.$img4.'"'.'target="_blank"><img width="120" height="120" src="'.$fullpath4.'"></a>'; } }else{ echo '<img width="120" height="120" src="'.$imgpath4.'O/ONP.gif">'; } echo '<br><font color="#000000" face="Trebuchet MS"><b>'.$img4."</b></font></td>"; /* No 5 Leaf */ echo '<td width="17%" height="7" bgcolor="#009900" align="center">'; if (file_exists($partpath5)){ echo '<img width="120" height="120" src="'.$fullpath5.'">'; }else{ echo '<img width="120" height="120" src="'.$imgpath5.'N/NPA.jpg">'; } echo '<br><font color="#000000" face="Trebuchet MS"><b>'.$img_5."</b></font></td>"; echo '</tr>'; echo '<tr><td colspan=5> </td></tr>'; } if(count(@$results[0])==0){ echo '<tr><td width="100%" colspan=5 align="center">No results found.</td></tr>'; } ?> </table> <font size="2"><b></b></font></div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/178842-whats-wrong-with-this-code/ Share on other sites More sharing options...
Mark Baker Posted October 24, 2009 Share Posted October 24, 2009 The file referenced in $partpath5 doesn't exist. Check the value of $partpath5 to see if it's really pointing where you expect it to Link to comment https://forums.phpfreaks.com/topic/178842-whats-wrong-with-this-code/#findComment-943487 Share on other sites More sharing options...
bonanzab Posted October 24, 2009 Author Share Posted October 24, 2009 It's pointing to the right path, also if the path is wrong, it would not work on the website Link to comment https://forums.phpfreaks.com/topic/178842-whats-wrong-with-this-code/#findComment-943502 Share on other sites More sharing options...
Mark Baker Posted October 24, 2009 Share Posted October 24, 2009 Well clearly your microweb server disagrees, otherwise it would return true for file_exists() Double check exactly what value you have in $partpath5, and the actual file path and name, paying particular attention to factors like case-sensitivity, spaces in the path/filename, etc. Link to comment https://forums.phpfreaks.com/topic/178842-whats-wrong-with-this-code/#findComment-943561 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.