Dont think my syntax is right message box not appearing.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Beebosoft
Forum Newbie
Posts: 12
Joined: Mon Jun 25, 2007 9:18 am

Dont think my syntax is right message box not appearing.

Post by Beebosoft »

I have a page where the sure can cancel a booking and want a message bot to appear to check they really want to do this. I put sone code in which works is just in html but isn't bringing up a message box .
The code I am using is as follows

Code: Select all

print "<a href ='delete.php?id=$bookingid' onclick='if (confirm('Are you sure you want to cancel this booking? or \nCancel if you do not want to. ')){return true}else{return false}'>Cancel</a>";

Any help would be appreciated.
Nuts
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Escape the quotes. This is what you are actually outputting (note the highlighting):

Code: Select all

<a href ='delete.php?id=$bookingid' onclick='if (confirm('Are you sure you want to cancel this booking? or \nCancel if you do not want to. ')){return true}else{return false}'>Cancel</a>
Beebosoft
Forum Newbie
Posts: 12
Joined: Mon Jun 25, 2007 9:18 am

Post by Beebosoft »

I am sorry I am being really thick today. I am not sure what you mean by escape the quotes.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

You can't have single quotes nested in single quotes. You can't have double quotes nested in double quotes. You have to escape the others.

Code: Select all

echo 'This is how you \'escape quotes\'.';
Beebosoft
Forum Newbie
Posts: 12
Joined: Mon Jun 25, 2007 9:18 am

Post by Beebosoft »

I have put the escape quotes in now thank you for that info but it is still not bringing up a message. I have included the whole line

Code: Select all

print "<tr><td>$courseid</td><td>$name</td><td>$email</td><td>$phone</td><td>$add</td><td>$postcode</td><td>$company</td><td>$datebooked</td><td><p><a href ='delete.php?id=$bookingid' onclick='if (confirm(\'Are you sure you want to cancel this booking? or Cancel if you do not want to. \')){return true}else{return false}'>Cancel</a></p></tr>";
Any help appreciated
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

Code: Select all

print "<tr><td>$courseid</td><td>$name</td><td>$email</td><td>$phone</td><td>$add</td><td>$postcode</td><td>$company</td><td>$datebooked</td><td><p><a href ='delete.php?id=$bookingid' onclick=\"if (confirm('Are you sure you want to cancel this booking? or Cancel if you do not want to. ')){return true}else{return false}\">Cancel</a></p></tr>";
Post Reply