Small syntax error

Thread Solved

Join Date: Sep 2009
Posts: 11
Reputation: debuitls is an unknown quantity at this point 
Solved Threads: 0
debuitls debuitls is offline Offline
Newbie Poster

Small syntax error

 
0
  #1
Sep 16th, 2009
Hi all,

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

  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

  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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 827
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 135
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark

Re: Small syntax error

 
0
  #2
Sep 16th, 2009
what is the error ?
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 11
Reputation: debuitls is an unknown quantity at this point 
Solved Threads: 0
debuitls debuitls is offline Offline
Newbie Poster

Re: Small syntax error

 
0
  #3
Sep 16th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 827
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 135
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark

Re: Small syntax error

 
0
  #4
Sep 16th, 2009
Not sure, if I put this:
  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.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 72
Reputation: smartness is an unknown quantity at this point 
Solved Threads: 10
smartness's Avatar
smartness smartness is offline Offline
Junior Poster in Training

Re: Small syntax error

 
0
  #5
Sep 16th, 2009
This works for me, this sent me to:
http://localhost/bookview.php?id=4&hn=victory


  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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 20
Reputation: SAMAEL is an unknown quantity at this point 
Solved Threads: 3
SAMAEL's Avatar
SAMAEL SAMAEL is offline Offline
Newbie Poster

Re: Small syntax error

 
0
  #6
Sep 16th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 11
Reputation: debuitls is an unknown quantity at this point 
Solved Threads: 0
debuitls debuitls is offline Offline
Newbie Poster

Re: Small syntax error

 
0
  #7
Sep 16th, 2009
Thanks for your suggestions guys.

Just resolved this.

The syntax

  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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 72
Reputation: smartness is an unknown quantity at this point 
Solved Threads: 10
smartness's Avatar
smartness smartness is offline Offline
Junior Poster in Training

Re: Small syntax error

 
0
  #8
Sep 16th, 2009
also, don't forget hn=
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC