PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 9th, 2012, 09:34 AM
tyler_long_sim tyler_long_sim is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 13 tyler_long_sim User rank is Corporal (100 - 500 Reputation Level)tyler_long_sim User rank is Corporal (100 - 500 Reputation Level)tyler_long_sim User rank is Corporal (100 - 500 Reputation Level)tyler_long_sim User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 h 23 m 4 sec
Reputation Power: 0
PHP-General - Uncaught ReferenceError: set_cookie is not defined

i get this error in this code when i look in the console on Google chrome:

Uncaught ReferenceError: set_cookie is not defined

this is the code:



<script src="js/lightbox.js"></script>
<link href="css/lightbox.css" rel="stylesheet" />
<script type="text/javascript">
function set_cookie(){
document.getElementById("cookie").innerHTML="<?php cookie_set() ?>";
}
$("#overlay").hide();
</script>

<?php
function cookie_set()
{
setcookie("allow_cookies","true",time() + (20 * 365 * 24 * 60 * 60));
}
?>

Reply With Quote
  #2  
Old December 9th, 2012, 09:39 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 2012
Location: Germany
Posts: 2,047 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 h 9 m 25 sec
Reputation Power: 812
That code doesn't tell us anything. Where is that set_cookie() called? The console gives you the specific line of the error.

Last edited by Jacques1 : December 9th, 2012 at 09:44 AM. Reason: nonsense

Reply With Quote
  #3  
Old December 9th, 2012, 09:44 AM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,907 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 1 Month 1 Day 22 h 32 m 58 sec
Reputation Power: 581
Your code doesn't make any sense. You are substituting a return value from cookie_set into your JavaScript definition but cookie_set does not return anything. That is not a normal PHP error message. There is no line number in the message.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Reply With Quote
  #4  
Old December 9th, 2012, 09:48 AM
tyler_long_sim tyler_long_sim is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 13 tyler_long_sim User rank is Corporal (100 - 500 Reputation Level)tyler_long_sim User rank is Corporal (100 - 500 Reputation Level)tyler_long_sim User rank is Corporal (100 - 500 Reputation Level)tyler_long_sim User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 h 23 m 4 sec
Reputation Power: 0
set_cookie() is called by this:

<input name="ok_hide" type="button" onClick="set_cookie()" value="Ok, i get it.">

i want it to set a cookie, hide the button but i dont want it to redirect.

Reply With Quote
  #5  
Old December 9th, 2012, 09:56 AM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,907 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 1 Month 1 Day 22 h 32 m 58 sec
Reputation Power: 581
That makes even less sense. A JavaScript call will not redirect unless you program it to. PHP will never see that call anyway. You need to understand that JavaScript is client side and PHP is server side. Look at the source in your browser, is that what you expect for your JavaScript function definition?

Last edited by gw1500se : December 9th, 2012 at 09:58 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - Uncaught ReferenceError: set_cookie is not defined

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap