-
Posts
5,449 -
Joined
-
Days Won
174
Everything posted by mac_gyver
-
if the time is actually after 24 minutes of inactivity, it's due to the session data files being deleted due to the default value for session.gc_maxlifetime of 1440 seconds. in general, if you need to have sessions persist for longer periods of inactivity, you need to set session.gc_maxlifetime to a longer/reasonable value. if the time seems to vary, its likely a script running on the server is setting session.gc_maxlifetime to a fairly short value (usually done to automatically 'log' people out), which is causing the session data files to be deleted. you would need to find the script doing this and change it to not use session.gc_maxlifetime for this purpose. to automatically log people out, you need to store the last access time and check on each (the next) page request how much time has gone by since the last request to automatically log someone out.
-
you are able to insert information into your database table because your query specified the database_name.table_name - i.e. `teaching`.`campus`. your select query won't work without either selecting the database in the php code or specifying the database name along with the table name. consistency counts along with brevity/clearness in coding. since most applications will have only one database, you should select the database in your php code and leave it out of the query statements. your usage of $_PHP_SELF is incorrect. the only reason it works as a form action is because an empty/nonexistent variable will result in an empty action='' attribute. however, when you turn on php's error reporting this will be replaced by a php error message and then won't submit (you will typically get a 404 error because using the php error message as a url to submit the form to doesn't exist.) after you set php's error_reporting and display_errors as suggested in your php.ini, for the master php.ini, you will need to restart your web server to get the changes to take effect. you should also confirm that the changes were made to the php.ini that php is using by looking at the output from a phpinfo() statement. this is the line running your select query - $retval_selectcompany = mysql_query( $sql_select, $conn ); it has no error checking, so you don't know if or why it is failing (currently the while(){} loop trying to retrieve the data will throw a php error, if php's error reporting/display errors were on, about the result resource and the loop will be skipped over.) this is your error checking logic after the insert query is executed - if(! $retval ) { die('Could not enter data: ' . mysql_error()); } you need to do something similar after the select query so that any query errors will be detected and reported (you will be getting a 'no database selected' error in the current code.) the reason those replying to you in this thread know that the 4th parameter in the mysql_connect() function isn't the database (it's a flag that forces a new database connection, in mysqli it is the database name), that you need to select the database in the posted code so that all the queries will work, that there are not that many differences between using the mysql and mysqli functions, and that $_PHP_SELF isn't a php variable (past or current) is because we have studied those specific sections in the php.net documentation as part of our learning and experience and would not have taken the time to write out what your posted code is doing incorrectly if it wouldn't have been of help to you.
-
you need to find out why your query isn't matching a row in your database table.
-
echo your $query variable to see if it contains expected values for the student_id and student_password. if it does, copy the resulting sql query and run it directly against your database using your favorite database management tool (i.e. phpmyadmin or similar) to see if it actually matches a row in your database table. if it doesn't, determine which of the three values in the WHERE clause don't match the row you have in your database table. edit: also, what does var_dump($date); show?
-
your getfile.php isn't outputting a web page. the ONLY things it outputs are the correct content type header followed by the file contents.
-
Need Result Coading for my school website plzz
mac_gyver replied to akraees's topic in PHP Coding Help
just listing what you want is not a question. that's a statement of having a need and in programming, you must either do the work to satisfy that need or hire someone to do this for you. you need to stop posting on a help forum if you haven't made any attempt at researching and doing this yourself. -
this is apparently part of a class/course. whomever is teaching should have shown some basic troubleshooting tips to get php and your code to help you. 1) you need to set php's error_reporting to E_ALL and display_errors to ON in your php.ini to get php to help you. 2) you need to always check for query errors. you are checking if your connection and the insert query is working, but you are not checking and reporting if the select query is working. the above two suggestions will have been producing php errors and/or query errors that would alert you to the fact that your database connection isn't present when you try to run the select query and you will also get a mysql error (after you have a connection present for both queries) telling you that you are not selecting a database. the 4th parameter of the msyql_connect() statement is not the database name. you need to use a mysql_select_db() statement to select a database. you will also be getting a php error due to the $_PHP_SELF. that variable doesn't exist at all and in the older php versions where something like that variable did exist, it would have been $PHP_SELF. you should be using $_SERVER['PHP_SELF'] in your form's action='' attribute or more simply just leave the action='' attribute empty to submit to the same page. lastly, the mysql_ (no i) functions are depreciated and will be removed in a future version of php. you need to use the mysqli or PDO database functions so that you don't need to rewrite your code when the mysql_ functions get removed from the php language.
-
if you revisit this thread, a couple of words about your code. you have too much of it. you should not repeat yourself when coding. you should also separate your data from your code (i.e. make a data driven design) so that when you need to change or update the data, it's all in one place (or could even be stored in a database and retrieved.) an example of how you could write the posted code - <?php list($check,$data) = validate ($dbc,$_POST['email'],$_POST['pass']); if ($check) { session_start(); date_default_timezone_set('UTC'); $_SESSION[ 'user_id' ] = $data[ 'user_id' ]; $_SESSION[ 'first_name' ] = $data[ 'first_name' ]; $_SESSION[ 'last_name' ] = $data[ 'last_name' ]; $_SESSION[ 'team' ] = $data[ 'team' ]; $_SESSION[ 'email' ] = $data[ 'email' ]; // not sure what your team == 'BR' else really means, but define your schedule somehow as just the data needed - $BR['bury'] = "15-02-2014"; $BR['scunthorpe'] = "25-02-2014"; $BR['northampton'] = "01-03-2014"; $BR['hartlepool'] = "15-03-2014"; $BR['fleetwood'] = "25-03-2014"; $BR['wimbledon'] = "29-04-2014"; $BR['portsmouth'] = "19-04-2014"; $BR['wycombe'] = "28-04-2014"; $non_BR['orient'] = "11-02-2014"; $non_BR['sheffutd'] = "22-02-2014"; $non_BR['shrewsbury'] = "08-03-2014"; $non_BR['peterborough'] = "11-03-2014"; $non_BR['colchester'] = "22-03-2014"; $non_BR['rotherham'] = "29-03-2014"; $non_BR['walsall'] = "12-04-2014"; $non_BR['stevenage'] = "21-04-2014"; $non_BR['crawley'] = "03-05-2014"; if ($_SESSION['team'] == 'BR' ) { $schedule = $BR; } else { $schedule = $non_BR; } $fixture = date('Y-m-d'); $found = false; foreach($schedule as $team=>$date){ if($fixture <= date('Y-m-d',strtotime($date)){ $found = true; load("teams/{$team}.php"); break; } } if(!$found){ echo "No remaining fixtures left for season 2013/2014"; } }
-
in order to compare dates using greater-than/less-than, the format must be date('Y-m-d'), i.e. most-significant (year) to least-significant (day) so that the values will be compare by magnitude. your date('d-m-Y') format is comparing the day first, then the month, then the year.
-
looking for some info on mysql + php please!
mac_gyver replied to LisaDee's topic in PHP Coding Help
that part is easy, you just make a view for your table that matches the valid/non-deleted rows and use that view name as the table name in your queries. you would query using the original table name when you want to operate on all the rows, deleted and non-deleted. -
Most efficient way to select from several tables
mac_gyver replied to BenWeston's topic in MySQL Help
you would need to use a JOIN'ed query to retrieve related information using one query. -
Need Result Coading for my school website plzz
mac_gyver replied to akraees's topic in PHP Coding Help
if your question is, will a programming help forum help you with your code, yes, post your code and the error or problem you are having with the code you wrote. if you need design help, such as a question about how you should accomplish a part of the task, post in the Application Design forum section. -
best guess is the php.ini settings are different between running as a scheduled task and via the command line and you are running up against the max_execution_time value. do you have php's error_reporting set to E_ALL and log_errors set to ON so that all php errors will be logged? also, are you checking if each query is failing and logging the reason why? you could also log the ini_get('max_execution_time'); value to see if it is different between running as a scheduled task and via the command line. you could also capture and log/store to a file the phpinfo(INFO_GENERAL) output to see if any php.ini is being used and/or log/store to a file the complete phpinfo() output and compare them to see if there are any differences.
-
Form not Updating new password in database
mac_gyver replied to SalientAnimal's topic in PHP Coding Help
yes, but did you look at that and even try to solve the problem? at this point, all you are doing is dumping your code, errors, and data on a forum and expecting someone else to fix your code for you. make an attempt and others will help you when you truly get stuck with a coding problem. where you are stuck at now is not even looking at what is happening in your code. -
Form not Updating new password in database
mac_gyver replied to SalientAnimal's topic in PHP Coding Help
that message is the result of a conditional test in your code having a true value. have you looked at the values being tested by that conditional statement so that you would know which one(s) are not the expected values and are causing that message to be output? -
the example code i posted contains a comment in it where you would put the code needed to take the submitted drop-down value, validate it and produce a conditional statement that you can add to the mysql query to serve as a filter - so far you have not even shown your attempt at producing that logic, let along putting it into any code. the code i posted functions and retrieves all (since it doesn't have any filtering logic in it) the data from your tables (tested). i'm sorry but the point of programming help is we don't post copy/paste solutions and it appears that would be the only way this thread is going to move forward.
-
Need some help filling a form based on user selectection in dropdown..
mac_gyver replied to A JM's topic in PHP Coding Help
your form that's going to submit the final data has to be valid and have the proper type of inputs. this is one of the reasons why i stated you need to be able to get this to work first without using ajax, as the core code needs to be present and working. -
Need some help filling a form based on user selectection in dropdown..
mac_gyver replied to A JM's topic in PHP Coding Help
the example that davidannis gave actually produces the html for the form field he was using, i.e. a select/option menu, then sending the html through ajax to be put into the html of the form. to just put values into type='text' form fields, you would give each form field its own id, then set the value attribute, something like - document.getElementById("city").value = update[3]; // whatever offset corresponds to the 'city' id form field -
Multiple Table Query, while inside a while, results=table length?
mac_gyver replied to devil614's topic in PHP Coding Help
$ect_item_monster_data is an array of arrays (one main array for each eitem_id) holding the rows (each row is an array as well) that the JOIN'ed query produced. id would recommend that you use echo '<pre>',print_r($ect_item_monster_data,true),'</pre>'; so that you can SEE what it contains, so that you will be able to understand what the foreach loop is doing. -
when you use a method='get' form, ONLY the form fields are passed on the end of the url when the form is submitted. you will need to pass the country as a hidden field in the form.
-
http://dev.mysql.com/doc/refman/5.5/en/example-maximum-column-group-row.html
-
PHP / Extension API mismatch
mac_gyver replied to demonweare's topic in PHP Installation and Configuration
you need to state what version of windows (if it's xp, you cannot use php5.5.) you need to state if you are running php as an apache module or as a cgi application (as an apache module, you must use the thread-safe version of php and any php extensions, as a cgi you should use the non-thread safe version but i believe the thread-safe version will run.) in any case, all the php core files and extensions must have been complied together (as long as you have gotten them from the same php.net download, there should be no problem.) you need to state where you obtained the apache binary from (apache.org or apachelounge, the apache.org binary still uses VC6 (Visual C++ Redistributable) and you should use only the VC6 builds of php, of which php5.4 and 5.5 are not.) you need to state what version of the Microsoft Visual C++ Redistributable Package you have and if you updated it. and you need to stated HOW you originally obtained and installed php5.3 (the msi installer or manually using the .zip package) and state the procedure you used to upgraded php. -
Multiple Table Query, while inside a while, results=table length?
mac_gyver replied to devil614's topic in PHP Coding Help
i finally figured out WHAT you are trying to, i.e. loop over the ect items and display any monster's data for each item. here's how you would do this - in the business logic getting the data - // note: you should be building your WHERE clause in a variable so that it can be used in each place it is needed without repetition of code // get the ect item data w/the id as the key (to allow all id's to be extracted at once) $query = "SELECT * FROM etcitem $where ORDER BY $omethod $smethod"; $result = mysql_query($query); $ect_item_data = array(); while($row = mysql_fetch_assoc($result)){ $ect_item_data[$row['item_id']] = $row; } // get the monster data that are using the ect item id's if(!empty($ect_item_data)){ // only do this if there are matching items/ids $ids = implode(',',array_keys($ext_item_data)); // get a list of ids $query = " ........ WHERE some_column_reference IN ($ids) ......"; // query to get all the monster data using the ect_item ids $result = mysql_query($query); $ect_item_monster_data = array(); while($row = mysql_fetch_assoc($result)){ $ect_item_monster_data[$row['item_id']][] = $row; // this is stored as arrays of arrays using the ectitem.item_id as the main array index } } note: i didn't actually write or fix your query (the Olympics are currently on), only showed the IN ($ids) term that gets all the matching rows at once. you will need to work on producing the correct query. in your presentation logic producing the output from the data - if(empty($ect_item_data)){ // no ect item data found at all, output your 'no result' content here... } else { // loop over the ect items foreach($ect_item_data as $row){ // output your item heading here.... // check if there is any monster data for this item $eitem = $row['item_id']; if(!count($ect_item_monster_data[$eitem])){ // no monster data for this item, output your 'no result' content here... } else { // one or more monsters use this item, output that here... foreach($ect_item_monster_data[$eitem] as $arr){ // reference the $arr[...] elements to output the data for the monster here... } } } } -
Multiple Table Query, while inside a while, results=table length?
mac_gyver replied to devil614's topic in PHP Coding Help
i have a recommendation that needs to come even before learning how to join your tables in a query, you need to separate your 'business logic' (the php logic that is determining what to do on the page and retrieving the data you need) from your 'presentation logic' (minimal php code and the html/javascript/css making up the output you are sending to the browser.) basically, a majority of the php code will be first on the page, followed at the end by essentially a html template that is just echoing php variables or at most looping over arrays of data producing the html output from that data. by doing this, the logic that is retrieving the relevant data will be together in one place so that you (or us) will be able to see why your code isn't doing what you want. then, once your code is retrieving the correct data, producing the output from that data is a straight-forward task. here's an example showing the separation of business/presentation logic - http://forums.phpfreaks.com/topic/286008-use-dropdown-box-to-filter-data-on-same-page/?hl=%2Bbusiness&do=findComment&comment=1468017