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
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]

Link to comment
Share on other sites

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>'

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.