EMERGENCY: My code crashed - please help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dsabot
Forum Newbie
Posts: 1
Joined: Fri Jan 23, 2004 2:28 am

EMERGENCY: My code crashed - please help

Post by dsabot »

Let me start off by saying thanks in advance. I have no programming experience and made a HUGE mistake. We have a website that is run off of MySql and PHP. I went into a file on the server using an ASCII editor and changed 1 word of a text phrase. I saved and uploaded to the server and all hell broke loose. Now my product images are not showing up.

I am hoping somebody here can look at the following code and tell me what I need to do. Remember, I am a novice here. I can modify and upload, but beyond that. I need this done asap as my boss will kill me if he knew I downed his website. The code is as follows:

<?
$rs = $db->query("select * from $config[products_table] where pid='$pid'");if ($rs->RecordCount() > 0) {
?>
<table width="100%">
<tr>
<td colspan="2" align="center" style="padding-bottom:20px;">
<!-- Product Name and description -->
<span style="font-size:26px;">

<?echo $rs->fields[name]
?>

</span> <br> <span style="font-size:20px;">

<?echo $rs->fields[description]
?>
</span> <!-- End Product Name and description -->
</td></tr><tr> <td>
<!-- Product images -->

<?$largeImgDir="".$config[root_dir]."/".$config[prod_img_dir]."/";$d = dir($largeImgDir);while($entry = $d->read()) {//here it is excluded backup dir, preventing a loop $explodedEntry = explode(".", $entry); if ($explodedEntry[0] == $rs->fields[pid]) { $largeImgList[] = $entry;}}for ($i = 0 ; $i < sizeof($largeImgList) ; $i++) {?>

<img src="<?echo $config[prod_img_dir];echo "/";echo $largeImgList[$i]?>" border="0"><br><?}?>

<!-- End product images -->
</td><td valign="top" style="font-size:12px;"> <!-- Product details -->

<?echo $rs->fields[details]?> <br> <br> <!-- EXTRA INFO --><?if ($rs->fields[capacity]) {?>Capacity : <?echo $rs->fields[capacity]?><br><?}?><?if ($rs->fields[inside_dim]) {?>Inside Dimensions : <?echo $rs->fields[inside_dim]?><br><?}?><?if ($rs->fields[outside_dim]) {?>Outside Dimensions : <?echo $rs->fields[outside_dim]?><br><?}?><?if ($rs->fields[qty_per_case]) {?>Quantity per case : <?echo $rs->fields[qty_per_case]?><br><?}?><?if ($rs->fields[case_dim]) {?>Case Dimensions : <?echo $rs->fields[case_dim]?><br><?}?><?if ($rs->fields[case_weight]) {?>Case Weight : <?echo $rs->fields[case_weight]?><br><?}?><?if ($rs->fields[piece_weight]) {?>Piece Weight : <?echo $rs->fields[piece_weight]?><br><?}?><!-- END EXTRA INFO --> <div align="center"> <br> <strong> Item #<?echo $rs->fields[nr]?> <br> <a name="stock"> <?if ($submitAuth && $isLogged) {?> <script>document.location.href='#stock'</script> <span style="background-color:yellow;"><?}?> Availability: <?if ($submitAuth && $isLogged) {?> </span><?}?> </a> <?if (!$isLogged) {?> Wholesale Inquiries Only <?} else {?> <?echo $rs->fields[instock]?> <?}?> </strong> </div> <!-- End Product details --> </td> </tr><?if ($users[info][session][level] > 70){?><tr colspan="2" align="center"> <td><a href="?file=1&go=admproducts&sub=edit&pid=<?echo $rs->fields[pid]?>">[edit product]</a> - <a href="?file=1&go=admproducts&act=delete&pid=<?echo $rs->fields[pid]?>">[delete product]</a> </td></tr><?}?></table><?} else {?>Please specify a product to display.<?}
?>


You can see that everything works fine, but the images are not showing up. Here is the URL for a sample page:

http://www.qualityimporters.com/?go=pro ... ils&pid=27

Please email me at dave@qualityimporters.com if you know how to fix this.

God Bless.
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

What did you change ? Was it on this page ?
Dr Evil
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

After a very brief glance: change all arrays to double-quotes instead of no quotes at all. For example

$rs->fields[capacity]

becomes

$rs->fields["capacity"]
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

The code on this page is a mess. Did you copy it fro the source directly. I see a few comments that cancel certain lines of code.

What did you open it with ?

Dr Evil
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Try this - I haven't changed the code structure, but this should work.

If it works, I believe you accidentially commented out a line by deleting a linefeed.

Code: Select all

<?php
<?
$rs = $db->query("select * from ".$config['products_table']." where pid='$pid'");if ($rs->RecordCount() > 0) {
?>
<table width="100%">
<tr>
<td colspan="2" align="center" style="padding-bottom:20px;">
<!-- Product Name and description -->
<span style="font-size:26px;">

<?echo $rs->fields["name"]
?>

</span> <br> <span style="font-size:20px;">

<?echo $rs->fields["description"]
?>
</span> <!-- End Product Name and description -->
</td></tr><tr> <td>
<!-- Product images -->

<?$largeImgDir="".$config["root_dir"]."/".$config["prod_img_dir"]."/";$d = dir($largeImgDir);while($entry = $d->read()) 
{
	//here it is excluded backup dir, preventing a loop 
	$explodedEntry = explode(".", $entry); if ($explodedEntry[0] == $rs->fields['pid']) { $largeImgList[] = $entry;}}for ($i = 0 ; $i < sizeof($largeImgList) ; $i++) {?>

<img src="<?echo $config['prod_img_dir'];echo "/";echo $largeImgList[$i]?>" border="0"><br><?}?>

<!-- End product images -->
</td><td valign="top" style="font-size:12px;"> <!-- Product details -->

<?echo $rs->fields["details"]?> <br> <br> <!-- EXTRA INFO --><?if ($rs->fields["capacity"]) {?>Capacity : <?echo $rs->fields["capacity"]?><br><?}?><?if ($rs->fields["inside_dim"]) {?>Inside Dimensions : <?echo $rs->fields["inside_dim"]?><br><?}?><?if ($rs->fields["outside_dim"]) {?>Outside Dimensions : <?echo $rs->fields["outside_dim"]?><br><?}?><?if ($rs->fields["qty_per_case"]) {?>Quantity per case : <?echo $rs->fields["qty_per_case"]?><br><?}?><?if ($rs->fields["case_dim"]) {?>Case Dimensions : <?echo $rs->fields["case_dim"]?><br><?}?><?if ($rs->fields["case_weight"]) {?>Case Weight : <?echo $rs->fields["case_weight"]?><br><?}?><?if ($rs->fields["piece_weight"]) {?>Piece Weight : <?echo $rs->fields["piece_weight"]?><br><?}?><!-- END EXTRA INFO --> <div align="center"> <br> <strong> Item #<?echo $rs->fields["nr"]?> <br> <a name="stock"> <?if ($submitAuth && $isLogged) {?> <script>document.location.href='#stock'</script> <span style="background-color:yellow;"><?}?> Availability: <?if ($submitAuth && $isLogged) {?> </span><?}?> </a> <?if (!$isLogged) {?> Wholesale Inquiries Only <?} else {?> <?echo $rs->fields["instock"]?> <?}?> </strong> </div> <!-- End Product details --> </td> </tr><?if ($users["info"]["session"]["level"] > 70){?><tr colspan="2" align="center"> <td><a href="?file=1&go=admproducts&sub=edit&pid=<?echo $rs->fields["pid"]?>">["edit product"]</a> - <a href="?file=1&go=admproducts&act=delete&pid=<?echo $rs->fields["pid"]?>">[delete product]</a> </td></tr><?}?></table><?} else {?>Please specify a product to display.<?} 
?>
Post Reply