Jump to content

[SOLVED] Can anyone spot the syntax error


debuitls

Recommended Posts

Hi all,

 

I cant seem to spot the syntax error in this line of code.

 

I was wondering if anybody with a fresh pair of eyes can suggest what i'm doing wrong.

 

'<button type="button" onclick=\"window.location='results.php?id=". $row['proposalid'] . "'\">'."Book Now".'</button>'

 

Any suggestions would be much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/174434-solved-can-anyone-spot-the-syntax-error/
Share on other sites

Thanks very much for getting back to me MrAdam.

 

I gave your suggestion a try there and the syntax error was gone.

 

However, the page got a little distorted see example 1.

 

What I really want is for it to look like example 2.

However, the buttons in example two dont do anything.

I just created them using the code off the w3 schools site.

 

'<button type="button">'."Book me!".'</button>'

 

Wondering if anyone can solve my dilemma?

 

[attachment deleted by admin]

Ah my mistake, I went wrong too. I didn't actually know there was a "button" tag until now if I'm honest.

 

Going with the w3schools syntax then:

 

'<button type="button" onclick="window.location=\'results.php?id='. $row['proposalid'] . '\'">Book Now</button>'

Ah sorry, for wrecking your head now with this.

 

When I add in a second row to be appended to the URL I think i'm making another syntax mistake as the button doesnt do anything

 

*Sorry the code should actually read like this.

 

'<button type="button" onclick="window.location=\'bookview.php?id='. $row['bookingref'].'&hn'. $row['hotelname'].'\'">Book Now</button>'

 

Just wondering if anyone could shed some light on my mistake?

You shouldn't have the 2 single quotes between the buttons..

 

'<button type="button" onclick="window.location=\'bookview.php?id='. $row['bookingref'].'&hn'. $row['hotelname'].'\'">Book Now</button><button type="button" onclick="window.location=\'bookview.php?id='. $row['bookingref'].'&hn'. $row['hotelname'].'\'">Book Now</button>'

 

If you were to use a syntax highlighter, or learn string concatenation a little more you'll be able to correct these yourself.

Sorry thats my fault there for posting up the same code twice there.

 

This is the code I was meant to put up.

 

'<button type="button" onclick="window.location=\'bookview.php?id='. $row['bookingref'].'&hn'. $row['hotelname'].'\'">Book Now</button>'

 

Button doesnt go anywhere when you add the second row.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.