Jump to content

Recommended Posts

Hi all,

 

POSTED YESTERDAY IN MYSQL SECTION - PROBABLY THE WRONG SECTION!!! (+ have now used php tags with snippet)

 

 

 

I'm sorry I don't come around here much - but please could someone help...you've always been so helpful here.

 

A year or two ago I taught myself some php and mysql in order to create my first ever database.

 

It's worked fine eversince (though I'm sure the snippet of code I've included below is probably extremely basic and a bit long in the tooth too!!!)

 

I've just upgraded my VPS hosting and it has gone from MySQL 4 to version 5.0.5(?) and I'm getting the following error when tryint to run the pages...

 

"Parse error: syntax error, unexpected ';' in /var/www/vhosts/vintage-home.co.uk/httpdocs/textile_pages/textiles_fabpage.php on line 183

"

The follwing code is the whole 'piece' from around that line number - the code on line 183 is that in line 4 shown below (begins 'else {echo ?> onclick...')

 

Could someone please tell me where I'm going wrong or what syntax rules have chaged...

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

<div id="polaroid_outer1" 
     <?php
     if ($row_rs_textiles['image_1'] == "tx") { echo ">"; }
     else { echo ?> onclick="MM_goToURL('parent','../index_fab10.php?ItemCode=<?php echo $row_rs_item1['ItemCode'];?>&pagenum=<?php echo $row_rs_textiles['page_number']; ?>');return document.MM_returnValue"> <?php }?>
     <div id="polaroid1_status">
     <?php if ($row_rs_item1['Status'] == "S") {$polaroid_overlay1 = '../images_fab/vh_sold1.png';?> <img src= <?php echo $polaroid_overlay1; ?> border="0"/> <?php } ?>
     <?php if ($row_rs_item1['Status'] == "R") {$polaroid_overlay1 = '../images_fab/VH_reserved1.png';?> <img src= <?php echo $polaroid_overlay1; ?> border="0"/> <?php } ?>
     <?php if($row_rs_textiles['image_1'] == "tx") { echo "$largeblank"; } ?>
     </div>     
      <div id="pos_polaroid1">
     <img src= <?php echo ("../textile_files/".$row_rs_item1['ItemCode']."/".$row_rs_item1['ItemCode']."_polaroid1.jpg");?> border="0"/></div>
      <div id="pos_item_name1" align="center" class="polaroid_title">
     <?php if($row_rs_textiles['image_1'] == "tx") { echo "Watch this space..."; }
     else { echo $row_rs_item1['ItemTitle'];} ?>
      </div>
    </div>

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

Kind regards

 

Mikey B

Link to comment
https://forums.phpfreaks.com/topic/189836-please-help-am-just-a-bit-lost/
Share on other sites

MadTechie your a STAR!!!!!!

 

worked beautifully!!!!

 

Could you possibly give me a quickie noob explanation - whatsyntax rules changed and why/where it applies.

 

After making your suggested changes - it then went on to fall-over on later lines - all with the same syntax - when I corrected these it all worked.

 

I can't believe the spped of the response I've had here...wow!

 

I really enjoy doing what little php I can - it brilliant to 'make something happen' through your own coding - and it's why I'm looking for a simple explanation/update on my syntax so I can carry on doing stuff with php - I love it!

 

Kind regards

 

Mike

Sure,

lets create some examples,

Here is a simple if statement inside some HTML (inline coding)

some HTML<BR />
<?php
if(11 > 10){
  echo "11 is greater than 10<BR />";
}else{
  echo "11 is NOT greater than 10<BR />";
}
?>
More HTML

output is

some HTML

11 is greater than 10

More HTML

 

Now instead of using echo you could just close the PHP tags ie

some HTML<BR />
<?php
if(11 > 10){ ?>
  11 is greater than 10<BR />
<?php }else{ ?>
  11 is NOT greater than 10<BR />
<?php
}
?>
More HTML

and we get the same result :)

 

Now echo require one or more parameters

so

	echo "one"; //one
echo "two","three"; // twothree
echo "4","5","6"; // 456
echo ; //Failed Parse error: syntax error, unexpected ';' 

Now lets look at your error,

} else { echo ?> onclick="MM_goToURL('parent','../index_fab10.php?ItemCode=<?php echo $row_rs_item1['ItemCode'];?>&pagenum=

translates to

} else { echo  ;echo $row_rs_item1['ItemCode'];

when you remove the HTML code

onclick="MM_goToURL('parent','../index_fab10.php?ItemCode=

Now i know you maybe thinking where did that extra semi-colon come from..

surely it should be

echo  echo $row_rs_item1['ItemCode'];

and get a different error

Parse error: syntax error, unexpected T_ECHO

 

Well when you close a PHP tags ?>, it will close the last line for you

for example

<?php echo "one" ?>

is valid (not error) but get in the habit of closing them..

 

okay i hope that clears things up..

 

 

EDIT: As your offline I have marked this as solved, (you can un/solve it with the button bottom left) you can still post here but it save time for members willing to help

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.