debuitls Posted September 16, 2009 Share Posted September 16, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/174434-solved-can-anyone-spot-the-syntax-error/ Share on other sites More sharing options...
Adam Posted September 16, 2009 Share Posted September 16, 2009 You've actually got the syntax for an input button wrong, and the quotes were mixed up. Try this.. '<button type="button" onclick="window.location=\'results.php?id='. $row['proposalid'] .'\'" value="Book Now" />' Quote Link to comment https://forums.phpfreaks.com/topic/174434-solved-can-anyone-spot-the-syntax-error/#findComment-919388 Share on other sites More sharing options...
debuitls Posted September 16, 2009 Author Share Posted September 16, 2009 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] Quote Link to comment https://forums.phpfreaks.com/topic/174434-solved-can-anyone-spot-the-syntax-error/#findComment-919401 Share on other sites More sharing options...
Adam Posted September 16, 2009 Share Posted September 16, 2009 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>' Quote Link to comment https://forums.phpfreaks.com/topic/174434-solved-can-anyone-spot-the-syntax-error/#findComment-919410 Share on other sites More sharing options...
debuitls Posted September 16, 2009 Author Share Posted September 16, 2009 Thanks MrAdam! That worked perfectly! Quote Link to comment https://forums.phpfreaks.com/topic/174434-solved-can-anyone-spot-the-syntax-error/#findComment-919426 Share on other sites More sharing options...
debuitls Posted September 16, 2009 Author Share Posted September 16, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/174434-solved-can-anyone-spot-the-syntax-error/#findComment-919442 Share on other sites More sharing options...
Adam Posted September 16, 2009 Share Posted September 16, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/174434-solved-can-anyone-spot-the-syntax-error/#findComment-919447 Share on other sites More sharing options...
debuitls Posted September 16, 2009 Author Share Posted September 16, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/174434-solved-can-anyone-spot-the-syntax-error/#findComment-919449 Share on other sites More sharing options...
Adam Posted September 16, 2009 Share Posted September 16, 2009 There's nothing wrong with the syntax there. Show how you're outputting them both, including the echo / print statements. You can also check the source to find out exactly what you're getting. Quote Link to comment https://forums.phpfreaks.com/topic/174434-solved-can-anyone-spot-the-syntax-error/#findComment-919450 Share on other sites More sharing options...
debuitls Posted September 16, 2009 Author Share Posted September 16, 2009 Hi MrAdam You were correct it was not a syntax error. The hotelname value I was trying to pass through the URL had a comma in it. When I removed the comma it seemed to work fine. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/174434-solved-can-anyone-spot-the-syntax-error/#findComment-919488 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.