943,568 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 478
  • PHP RSS
Sep 16th, 2009
0

Small syntax error

Expand Post »
Hi all,

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

PHP Syntax (Toggle Plain Text)
  1. '<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

PHP Syntax (Toggle Plain Text)
  1. '<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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
debuitls is offline Offline
12 posts
since Sep 2009
Sep 16th, 2009
0

Re: Small syntax error

what is the error ?
Sponsor
Featured Poster
Reputation Points: 549
Solved Threads: 722
Bite my shiny metal ass!
pritaeas is offline Offline
4,156 posts
since Jul 2006
Sep 16th, 2009
0

Re: Small syntax error

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!

Thanks

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.
Last edited by debuitls; Sep 16th, 2009 at 9:27 am. Reason: mistake in original post
Reputation Points: 10
Solved Threads: 0
Newbie Poster
debuitls is offline Offline
12 posts
since Sep 2009
Sep 16th, 2009
0

Re: Small syntax error

Not sure, if I put this:
html Syntax (Toggle Plain Text)
  1. <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 ?
Last edited by pritaeas; Sep 16th, 2009 at 9:30 am.
Sponsor
Featured Poster
Reputation Points: 549
Solved Threads: 722
Bite my shiny metal ass!
pritaeas is offline Offline
4,156 posts
since Jul 2006
Sep 16th, 2009
0

Re: Small syntax error

This works for me, this sent me to:
http://localhost/bookview.php?id=4&hn=victory


php Syntax (Toggle Plain Text)
  1. <?php
  2. $row['bookingref'] = "4";
  3. $row['hotelname'] = "victory";
  4. echo '<button type="button" onclick="window.location=\'bookview.php?id='. $row['bookingref'].'&amp;hn='. $row['hotelname'].'\'">Book Now</button>'
  5.  
  6. ?>
Last edited by smartness; Sep 16th, 2009 at 9:52 am.
Reputation Points: 7
Solved Threads: 14
Junior Poster
smartness is offline Offline
103 posts
since Aug 2007
Sep 16th, 2009
0

Re: Small syntax error

Not a window.location. It's wrong ))
window.location.href = '' or window.location.reload(URL);
Last edited by SAMAEL; Sep 16th, 2009 at 11:10 am.
Reputation Points: 10
Solved Threads: 3
Newbie Poster
SAMAEL is offline Offline
20 posts
since Sep 2009
Sep 16th, 2009
0

Re: Small syntax error

Thanks for your suggestions guys.

Just resolved this.

The syntax

PHP Syntax (Toggle Plain Text)
  1. '<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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
debuitls is offline Offline
12 posts
since Sep 2009
Sep 16th, 2009
0

Re: Small syntax error

also, don't forget hn=
Reputation Points: 7
Solved Threads: 14
Junior Poster
smartness is offline Offline
103 posts
since Aug 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: UML Check
Next Thread in PHP Forum Timeline: How do i echo a variable in a php mysql query ?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC