Hi all,

Just wondering if anybody can spot the syntax error with the below.

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

It works fine when I just append one row to the URL like this

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

The button only stops workin when I append the second 'hotelname' row.

Think its just a syntax error but I cant manage to spot it.

Any suggestions would be much appreciated.

9 Years
Discussion Span
Last Post by smartness

Hi pritaeas

Oh sorry I should have said in my post.

When I click on the button it doesnt call bookview.php, it doesnt call any page!


Sorry can I also just mention that I made a mistake there in my original post both examples of code I gave should be pointed towards bookview.php and not results.php as I have in my second example.

Edited by debuitls: mistake in original post


Not sure, if I put this:

<button type="button" onclick="window.location='bookview.php?id=1&hn'">Book Now</button>

in a test.html file it tries to open bookview.php

Are you missing something else ? Or do you have javascript disabled ?

Edited by pritaeas: n/a


This works for me, this sent me to:

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

Edited by smartness: n/a


Not a window.location. It's wrong ))
window.location.href = '' or window.location.reload(URL);

Edited by SAMAEL: n/a


Thanks for your suggestions guys.

Just resolved this.

The syntax

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

was fine as was suggested.

The problem was that the value I was appending to the URL had a comma in it.

silly mistake

Thanks again

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.