Jump to content

bgrzinic

Members
  • Posts

    13
  • Joined

  • Last visited

bgrzinic's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello guys, I posted this Question in MYSQL thread accidentally, so I'll try to ask the same here since I use Oracle RDBMS. Need help regarding SQL and aggregate function. I would like to do max function (or some join or something else), to get max value of column, and other column with it also. Here's the code: SQL> select department_id, sum(salary) place_total from employees where department_id is not null group by department_id; Previous query outputs this: DEPARTMENT_ID PLACE_TOTAL ------------- ----------- 90 58000 20 19000 110 20300 50 17500 80 30100 60 19200 10 4400 Now, how to edit previous sql statement so it can output department_id, and max(place_total), so the output result is: DEPARTMENT_ID PLACE_TOTAL ------------- ----------- 90 58000 Anyone have an idea, how to do this ? Thanks !
  2. Not sure if I clearly explained. Let me try again. "ORDER BY place_total DESC LIMIT 1" in Oracle should be replaced with "rownum <= 1 order by place_total desc;". Al thought, I have done this, still I'm not getting correct result. It just outputs the 1st result which gets from schema by given query , which is the lowest id with the lowest salary. (tried with ASC/DESC also). How do I get the ID and salary or record with the greatest salary ?
  3. No, unfortunately this doesn't do the trick, I'm in Oracle environment, but this syntax also don't do the trick, which is the sam as you mentioned but in oralce syntax: select * from (select department_id, sum(salary) place_total from employees where department_id is not null group by department_id) tmp1 where rownum <= 1 order by place_total desc; , it outputs lowest, no meter if I se ASC or DESC in order by.
  4. Hello guys, need help regarding SQL and agregat function, here's the code: SQL> select department_id, sum(salary) place_total from employees where department_id is not null group by department_id; outputs: DEPARTMENT_ID PLACE_TOTAL ------------- ----------- 90 58000 20 19000 110 20300 50 17500 80 30100 60 19200 10 4400 Now, how to edit the current sql statement to output department_id, and max(place_total), so the output result is: DEPARTMENT_ID PLACE_TOTAL ------------- ----------- 90 58000 Anyone have an idea ? Thanks !
  5. OK, i'm not an expert too, but think this should work with no problems. Since paths to the css and other files are ok, (checked in the same file with regular HTML code and it's working), as You suggest, think that might be problem in mixture of classes and ids involved in an HTML heirarchy since i have my code written is such way. Anyway, I'll check all of the above You mentioned. Thank You on advices.
  6. Of course if I write inline style like this, it works fine: index.php --------------------------------------- $outputList .=' <div id="my_div" style="background-color:#666;"> </div>'; echo $outputList; --------------------------------------- , but not if style is included and linked from files head tag. Is this familiar thing how server side php generates code (without applying css to HTML) or You think I might have problem somewhere else ?
  7. I'm sorry, here is corrected code. This is an example. My point is that CSS - HTML relation is working fine in the same file, and style gets applied. But once the same code is embedded in php variable and outputted, style is lost. style.css ------------------- #my_div:{ background:url(images/send_msg2.png) 0 0 no-repeat; } #my_div:hover{ background:url(images/send_msg2.png) 0 -34px no-repeat; } index.php: ----------------- <link href="style.css" media="screen, projection" rel="stylesheet" type="text/css" /> <!-- liked stylesheet --> $outputList .=' <div id="my_div"> </div>'; echo $outputList; Is anybody familiar with the problem ?
  8. Here You go: style.css ------------------- #send_img:{ background:url(images/send_msg2.png) 0 0 no-repeat; } #send_img:hover{ background:url(images/send_msg2.png) 0 -34px no-repeat; } index.php: ----------------- <link href="style.css" media="screen, projection" rel="stylesheet" type="text/css" /> <!-- liked stylesheet --> $outputList .=' <div id="my_div"> </div>'; echo $outputList; Result: Div is displayed, but without css applied, or without background img.
  9. Hello guys, I have a problem with embedded HTML. I have a php web page and few lines of HTML code (couple of div tags put in php variable. The problem is once I echo php variable that displays those DIVs, the style from linked CSS is lost or not applied. If I write HTML code to the same file directly, without embedding it into php, the style is applied correctly. What am I missing here ? Thanks!
  10. I would say that Your probably right. I have the img tag that points to non existant image. Also on 404 page is copy/pasted code from my index page that destroys session. Thank You very much for pointing me this out. Thank You guys and cheers.
  11. What confused me is that I noticed that on some page -> admin.php if i hit refresh no meter how many times, the session values are preserved, i can echo their values and it doesn't logout user. On the other hand, on page "profile.php" located in the same folder as admin.php, if i hit refresh I cannot echo session variable and user is logged out. Since those 2 pages are almost the same , I commented php code in profile.php and everything mysteriously worked fine. After deleting php code, the problem was the same. So, then i commented html and css code (just a few <div> elements) which had left in page, and everything works fine - i can echo session values. 1. I didn't know that this can effect php sessions. Can really html and css style affect php and php_sessions ? Now, i don't want to consume anyone time with nonsenses, I think this shouldn't affect php code, but yet it does. 2.Does anyone knows whats is going own, why few simple html/css elements interfere with php and point me on things I'm obviously missing and don't know ? Thanks.
  12. Thank You on reply. I have set error_reporting to E_ALL and log_errors set to ON, here is my php_error.log after restart of apache and navigatin through application: [14-Jul-2013 18:43:18] PHP Warning: session_destroy() [<a href='function.session-destroy'>function.session-destroy</a>]: Trying to destroy uninitialized session in /var/sms/404.php on line 11 [14-Jul-2013 18:43:18] PHP Warning: session_destroy() [<a href='function.session-destroy'>function.session-destroy</a>]: Trying to destroy uninitialized session in /var/sms/404.php on line 11 [14-Jul-2013 18:43:18] PHP Warning: session_destroy() [<a href='function.session-destroy'>function.session-destroy</a>]: Trying to destroy uninitialized session in /var/sms/404.php on line 11 [14-Jul-2013 18:43:18] PHP Warning: session_destroy() [<a href='function.session-destroy'>function.session-destroy</a>]: Trying to destroy uninitialized session in /var/sms/404.php on line 11 [14-Jul-2013 18:43:20] PHP Warning: setcookie() expects at least 1 parameter, 0 given in /var/sms/index.php on line 18 [14-Jul-2013 18:43:20] PHP Warning: session_destroy() [<a href='function.session-destroy'>function.session-destroy</a>]: Trying to destroy uninitialized session in /var/sms/index.php on line 20 Here are the lines from file that are listed in php_error.log: index.php: <?php //Start session //session_start(); require_once('functions.php'); sec_session_start(); if(isset($_SESSION['SESS_STATUS'])) {$status = $_SESSION['SESS_STATUS'];} if(isset($_SESSION['SESS_GRESKA'])) {$greska = $_SESSION['SESS_GRESKA'];} if(isset($_SESSION['SESS_GSM_BROJ'])) {$gsm_broj = $_SESSION['SESS_GSM_BROJ'];} if(isset($_SESSION['SESS_VRIJEME_SLANJA'])) {$vrijeme_slanja = $_SESSION['SESS_VRIJEME_SLANJA'];} if(isset($_SESSION['SESS_PORUKA'])) {$poruka = $_SESSION['SESS_PORUKA'];} if(isset($_SESSION['SESS_PORUKA_ZAPRIMLJENA'])) {$zaprimljena = $_SESSION['SESS_PORUKA_ZAPRIMLJENA'];} //Unset the variables stored in session $_SESSION = array(); session_unset(); session_write_close(); setcookie(); setcookie(session_name(),'',0,'/'); session_destroy(); /* line 20 */ session_regenerate_id(true); require_once('globalne_variable.php'); header('Content-type: text/html; charset=utf-8; Content-language:hr;'); ?> and 404.php <?php //Start session //session_start(); require_once('functions.php'); sec_session_start(); //Unset the variables stored in session $_SESSION = array(); session_unset(); session_write_close(); session_destroy(); /* line 11 */ setcookie(session_name(),'',0,'/'); session_regenerate_id(true); require_once('globalne_variable.php'); header('Content-type: text/html; charset=utf-8; Content-language: hr;'); ?> Index.php is also the login page, but I am not sure why is 404. php listed in error log since i haven called that page. Also I have checked in the browser, cookie with domain of application and name "sms_sess_sid" is created - it has settings defined with session_set_cookie_params in sec_session_start(). Do You have any new suggestions, clues ? Thanks on help.
  13. Hello, I'm not an php expert. I'm working on some php application and need help regarding php sessions or possibly something else. description application 1: On the apache server I have 1 php application/domain hosted in vhosts environment. Application has some protected pages and bulit in authentication logic, asks for username and password, retrives from mysql ans stores data into sessions. Application is hosted as virtual dir, it has its own domain1.com - This application is working fine, everything is ok. application2: On the same aoache/php server, as a vhost is hosted 2nd application, it has it's own domain2.com. It has the same builtin logic, but I expirience some wierd problems with sessions. Sessions values are lost once I call header("location: some_page.php"); , or if I refresh the same page - so for example once user logs in, if page is refreshed, session value user_id is lost and user is logged out. On every page, i 1st call the same sec_session_start() function, the same i use in Apllication1 which is working fine, but only with altered $session_name = 'sms_sess_sid' variable: function sec_session_start() { $session_name = 'sms_sess_sid'; // Set a custom session name $secure = false; // Set to true if using https. $httponly = true; // This stops javascript being able to access the session id. ini_set('session.use_only_cookies', 1); // Forces sessions to only use cookies. $cookieParams = session_get_cookie_params(); // Gets current cookies params. //session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly); session_set_cookie_params(3600, $cookieParams["path"], $cookieParams["domain"], $secure, $httponly); session_name($session_name); // Sets the session name to the one set above. session_start(); // Start the php session //session_regenerate_id(true); // regenerated the session, delete the old one. session_regenerate_id(); // regenerated the session, delete the old one. } On the start of every other page i call sec_session_start() like this: require_once('functions.php'); sec_session_start(); . In vhost.conf of second application i have added the line: php_value session.cookie_domain ".example-domain2.com" Problem: The problem is that in application2, on page refresh, or when navigating between pages, sessions and session_values are lost. Why is this happening ? Is there something that has to be configured specificly for multi application/domains/vhosts environment. What am I missing here ? Thank You in advanced.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.