jimfog
Members-
Posts
1,803 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Everything posted by jimfog
-
I want to create a function where I will include code related to the head section of a webpage(meta tags etc...). Do you think it will cause any problems(whatever might that be)?
-
One last thing,do you think it is better to have error reporting at E_ALL when developing?
-
The mistake I was doing is that I called only session_start and used the name of the variable($username) instead of $_session[.....]which is the correct in the function above.
-
Ok, how am I going to make the variable $username available to the other pages also by using session functionality?This is what is required here.Unless, session functionality is not required here-and the example you gave me will do the job.
-
I managed the solve the path issue-I had to make some adjustment at php.ini. Nonetheless there still is an issue.Here is the code in the first page-that sets the session: session_start(); $_SESSION['valid_user']=$username; The problem is in the second page-different of course from the one above, not related with the sessio path-here is the code: session_start(); <?php output_header('output_header_list',$username); I expected that $username would be valid and within the header code(not shown here) the username of the user would be printed, as this is what I am trying to achieve. Here is the error message I get: Notice: Undefined variable: username in C:\Apache24\htdocs\Appointments\Administrator\Calview.php on line Probably I do not do something correct-but what?
-
Yep...errors are beginning to come. [size=4][color=#333333][font=Monaco, monospace]Warning: session_start(): open(/tmp\sess_gc90vh0m8diqtgfbtvm3ococq5, O_RDWR) failed: No such file or directory (2) in C:\Apache24\htdocs\Appointments\Administrator\adminmember.php on line[/font][/color][/size] The funny thing is that at the page where the above message appears session functionality DOES WORK. Let us focus on the above for now, I do not want to go to the messages in subsequent pages-which might be irrelevant to the session problem. I will show the other message errors also if needed-I just do not want to overload us for now. As I side note: Is it maybe better if-when developing to have the errors set to E_ALL?
-
Οk...the reasons I asked about php.ini that I have problem implementing session control.Let me explain:In one page the session works(in the page where I set the session variable equal to the username).In fact I use the test code below to verify that everything is OK: echo 'the content of the session variable is'.$_SESSION['valid_user'] ; The problem appears in another page where the session variable IS NOT "kept" by PHP.There I use again session_start() to initiate the session but the session variable seems inactive-I used the test code above to verify it. below is the code I used in the 2 pages: $username=$_POST['username']; $passwd=$_POST['password']; session_start(); $_SESSION['valid_user'] = $username; try{ if (!filled_out($_POST)) { throw new Exception('Ουπς, δεν συμπληρώσατε τα στοιχεία -πίσω στην φόρμα λοιπόν για να τα συμπληρώσετε.'); } if ($username && $passwd) { // they have just tried logging in login($username, $passwd); output_header('output_header_list',$username);?> <div id="wrap"> <?php output_buttons(); echo 'the content of the session variable is'.$_SESSION['valid_user'] ; ?> The session above works perfectly fine-in the page below it does not work: <?php require_once 'output_functions_admin.php'; session_start(); ?> <body> <?php output_header('output_header_list',$username); ?> <div id="wrap"> <?php output_buttons(); echo 'the content of the session variable is'.$_SESSION['valid_user'] ; ?> The 2 code segments listed above(from 2 respective pages) it is only a portion of the whole scripts.I just included that piece of the code that will be enough for coming to a solution/conclusion.
-
So far we have not touched the issue of cookie/URL method for storing the session ID. The question is what is the preferred method forstoring the session ID according to your opinion. And another thing:I have installed PHP manual and as such I have not made any adjustments regarding session in php.ini. What do I have to do?
-
correct If I am wrong. A session should always start after the user has login or register-at these specific scripts.
-
The above phrase though, completes the puzzle-at least for now.
-
The thing that confused my is that the Is_callable had as an argument $function.We can use anything there provided that it is something that cannot be called. I used this for example:if (is_callable('tel')) { $function($username); and it still did the job.
-
Now I got it.There is one slight details though yet to complete the picture... We said $function is not callable-nonetheless, when output_header gets called, don;t we also call the inner function function(username) (by setting its value to false)which gave us the error and sparkled this all discussion? I hope you understand what I am talking about.
-
Let us see the code: function output_header($function=false,$username=false) {?><div id="header"> <div><a href="http://localhost/Appointments/Administrator/"> <img src="Images/logo.png" width="307" height="32" /></a></div> <?php if (is_callable($function)) { $function($username);} ?> </div><?php} if the argument $function is a function then the output of that if statement would be $function($username);I do not understand how this stops the error from appearing. I don't get it...
-
And the solution works(many thanks)-nonetheless I have not understood yet the underlying logic of is_callable
-
I am getting now somewhere, nonetheless I am surprised that $function($username) is treated like a function,given the fact I put dollar sign in front of it, which means the purpose was to have it treated like a variable. Now we I must find the solution to the problem...callable etc.
-
A small comment here.I set it to false because I assumed that $func is considered an argument of output_header. And arguments in PHP function CAN be set to false. And when you say "call it like a function"-you mean output_header() or output_header('output_header_list',$username) I assume you are referring to the first call.
-
I really cannot find where is the error here,here are the functions: function output_header($function=false,$username=false) {?><div id="header"> <div><a href="http://localhost/Appointments/Administrator/"> <img src="Images/logo.png" width="307" height="32" /></a></div> <?php $function($username); ?> </div><?php}function output_header_list($username){?> <ul id="headelem"> <li><?php echo $username ?></li> <li><a href="calendar.php">Calendar</a></li> <li><a href="login.php">log in</a></li> <li><a href="register_form.php">register</a></li> </ul> <?php } This works well: output_header('output_header_list',$username); This does not: output_header() ; I get the message I say above.As you see output_header gets declared with 2 arguments set at a default value of false-so there should not be a problem with calling the function withour arguments. According to the error message the problem lies at $function($username)-this is where the mistake is. But as I understand the above is needed(the way its syntax is) when calling output_header('output_header_list',$username);
-
So you are saying that in order for a function to be passed as an argument it MUST return something.Ok how am I going to "return" that html ul list in output_header_list-how exactly am I going to use the return keyword-from a syntax point of view? Your code works fine,nonetheless it is first time i see a function passed as an argument/string. Do we do this when the function we want to pass as a n argument to another function DOES not return something. There is a problem though... I call output_header 2 times in my script, one with arguments and one without. When it is with arguments(the code you gave ) it is ok.But with no arguments, I get the following error: Fatal error: Function name must be a string in C:\Apache24\htdocs\Appointments\Administrator\output_functions_admin.php on line 443 when i wrote the function, I set the arguments to false so as not have any errors when it is called without them: function output_header($output_header_list=false,$username=false) {?><div id="header"> <div><a href="http://localhost/Appointments/Administrator/"> <img src="Images/logo.png" width="307" height="32" /></a></div> <?php $output_header_list($username) ?> </div><?php} What can we do?
-
Here is the call-not shown in the example depicted in the beginning of the post:output_header(output_header_list($username)); With the above code, when output_header gets called, output_header_list($username)(which is the second function) gets passed as an argument. What do you think now?
-
In php.ini I found 2 display_error entries. I set them both to 1. Nonetheless no error message appears.So, I have 2 questions:1. Do I need to make other adjustments in php.ini-related to the display of errors.2.Is it certain that PHP outputs error when a non-existent file is "required"?
-
In php ini I found the following: ; display_errors=0; Default Value: Off; Development Value: On; Production Value: Off Which of the above I must uncomment? I will un comment display errors, as you suggest.
-
Are you suggesting(if understand correctly) that I do not call a function in a function and just use echo statements?
-
I might as well post in the html forum... The problem I am facing is that calling a function within a function messes with the html. Here is the code where the html is OK: function output_header($username=false) {?><div id="header"> <div><a href="http://localhost/Appointments/Frontend/"><img src="Images/logo.png" width="307" height="32" /></a></div> <ul id="headelem"> <li><?php echo $username ?></li> <li><a href="calendar.php">Calendar</a></li> <li><a href="login.php">log in</a></li> <li><a href="register_form.php">register</a></li> </ul></div><?php} And here is the code where the html is messed, a function is called inside a function, so below you will see 2 functions: function output_header_list($username){ ?> <ul id="headelem"> <li><?php echo $username ?></li> <li><a href="calendar.php">Calendar</a></li> <li><a href="login.php">log in</a></li> <li><a href="register_form.php">register</a></li> </ul> <?php }function output_header($output_header_list=false) {?><div id="header"> <div><a href="http://localhost/Appointments/Administrator/"> <img src="Images/logo.png" width="307" height="32" /></a></div> <?php $output_header_list ?> </div><?php} The problem is that instead of ul id="headelem" appearing within div id header(as depicted it the function output header) it appears out of it. Here is the image-from firebug:https://skydrive.live.com/redir?resid=BE27434B2AAC8130!243 Why the above happens?
-
Ι managed to find where the error was. I was requiring(require_once) a nonexistent file(had forgotten creating it). IF this counts as an Xdebug bug than I do not like the fact that the debbuger gives no indication at all there there is a fatal error. You are saying also that in order to find the exact error I must run the page without xDebug-I am assuming you mean, to run the script in Netbeans, because, when the page loads in the browser, I do not think XDebug has any effect on it-XDebug works only with in the "constraints" of the IDE. Yes it is easy sometimes to find error without message-as this is what I did in this case. And lastly, you are saying that I could see a message when a fatal error, how I can code that?By error logging I suppose you mean PHP error logs. Do these logs record all fatal errors?