Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,450
  • Joined

  • Days Won

    175

Everything posted by mac_gyver

  1. see the following link - http://forums.phpfreaks.com/topic/11572-multi-column-results/
  2. the point of ajax is for your main page to make requests to the server to either post data or get information to display on the page without refreshing the entire page. to do this, your first step will need to be to organize the logic on the page so that the there are distinct sections of code for producing the main page and for processing post and get ajax requests (and actually your get request to start a new game, since it modifies data on the server, should be handled as a post request.) it is actually possible to have one set of code work both with and without javascript/ajax. the only real difference is with javascript/ajax (there's a header in the request you can test to detect an ajax request), your php code would output the data back to the browser for the browser to display it, vs producing the finished html on the server and the php code outputting the html when the page is requested. i would also recommend a different layout for your main table, something like -
  3. the yii framework has it's own dedicated community/help forum, where you are more likely to get specific help with your questions, rather than on the multiple general php help forums you have been posting. also, please use the forum's bbcode tags (the edit form's <> button) around code you post.
  4. ^^^ in the above line in your code, there is no $id variable in your code, so that query is never finding anything, so the update branch logic never runs. if you had php's error_reporting set to E_ALL and display_errors set to ON, php would be outputting an undefined variable error to alert you to the problem with the $id variable. you don't need to select the data in order to find out if you should insert or update something, mysql has an INSERT ... ON DUPLICATE KEY UPDATE query - http://dev.mysql.com/doc/refman/5.6/en/insert-on-duplicate.html you can also use a LOAD DATA LOCAL INFILE query to import the data from a file.
  5. your program logic makes no sense. i recommend that you first define what inputs your code needs and will receive from your form and from your login system, then define what sort of processing you are trying to accomplish based on those inputs. some suggestions - 1) ALL the form processing logic needs to be inside of a conditional statement that is only true when the form has been submitted. this is so that your code doesn't produce a bunch of php errors and error messages from your logic when there isn't any $_POST data. 2) to compare the oldpass value with the current password hash stored in the database table, you will need to use the same hashing logic on the value from the form that was used when the current password hash was produced and stored. you will also need to fetch the current password hash from the database table. 3) if you don't already have real data stored for user's, you should be using php's password hash functions - http://php.net/manual/en/book.password.php 4) all the posted code is dependent on the visitor being logged in (i assume that check_login_status.php does this.) therefore, you should not be using any $_GET variable to tell your code who the current visitor is. you should be getting the current visitor's id from your login system. 5) you are running the SELECT... query two times in a row. why?
  6. the error contains that information (or lack of) because it's occurring before php passes control to any of your php scripts. the content size header is sent by the client to the web server at the start of the request. when the size is greater than the post max size setting, an abort response is sent back (for those clients that observe the response) to try and prevent the client from sending the too large of a file, then php processes the uploaded file, setting the $_FILES array values based on the result of the upload. php then passes control to the .php page that was requested. that's all the information that php has at the point where that error was detected. it would be up to your form processing code to detect when the upload didn't work and take an appropriate action. exceeding the post max size setting will result in empty $_FILES and $_POST arrays and can specifically be detected by checking the $_SERVER['CONTENT_LENGTH'] (which would be in bytes) vs the post_max_size setting (which may be in abbreviated notation, i.e. 20M.)
  7. you were subscribed to the php help forum section. had you bothered to look at the things that were posted in this thread, you could have stopped the emails yourself. all followed topics and forum sections have been removed from your account. you will need to modify the settings that CroNiX pointed out in his post above to prevent future email notifications.
  8. also, if you click on your username in the top-right-black-menu-bar on the page, one of the choices is Content I Follow, that will allow you to view and manage any topics or forum sections you are following.
  9. two error messages that indicate that your session variables don't exist, would mean that your log in code didn't log anyone in or that information didn't carry over to the index.php page. you would need to determine why by checking exactly what the log in code did when it ran or if there are any php or database errors in that code.
  10. most web servers have an access log that already contains this information.
  11. when debugging code, you need to have php's error_reporting set to E_ALL (or even better, a -1 ) and display_errors set to ON to get php to help you. if your code is running at all, you can put these settings into your main file(s), immediately after the first opening <?php tag. ini_set("display_errors", "1"); error_reporting(-1);
  12. this is from the myslqi connect_error documentation - it's recommended that you use the PDO database library, as it is much more consistent and easier to use.
  13. the name attributes in your form fields are not the same as the names being used in the php code $_POST['userName'] and $_POST['password'] variables.
  14. if you are expecting php code that's been placed inside a variable to run, that's not how php works. perhaps the following example will give you an idea how you might accomplish this - $files[] = $_SESSION['log_file']; $files[] = $_SESSION['monitor']; $files[] = $_SESSION['monitor.ini']; $files[] = $_SESSION['monitor_detected_file']; $files[] = $_SESSION['root_path'].'/'.'class.phpmailer.php'; $files[] = $_SESSION['root_path'].'/'.'class.smtp.php'; // add any other entries you want to include in the test here... if ( in_array($file_to_scan,$files)) { // code to run if $file_to_scan matches any of the entries in the $files array }
  15. since you posted in your existing thread after you created this thread, i'll assume you found the answer to your question yourself.
  16. the error is telling you what the problem is. the number of fields/columns you SELECT'ed in the query with the * doesn't match what you bound with the bind_result() statement. when you have reached the point of using prepared queries, it's best to list out each field/column you are selecting. this will also prevent problems should the order of the fields/columns in your database table get changed since you can see what exact fields/columns you are selecting and what order they will be in the fetched rows in the result set.
  17. the query will match rows that result in a TRUE value for the WHERE clause. AND has a higher operator precedence then OR, so your query is matching all rows with a city like $location or industry like $type or (zip like $location AND business like $type). to match the city or zip code like $location AND a business or industry like $type you would need to use - WHERE (`Primary_City` LIKE '%$location%' OR `Primary_Zip` LIKE '$location') AND (`Line_Of_Business` LIKE '%$type%' OR `Primary_Industry` LIKE '%$type%') next, you are not using prepared queries correctly. you must put place-holders in the query where the external data values are at, then bind the external data to those place-holders. since you are using a LIKE comparison, the wild-card % characters must actually be in with the bound data, not in the query (i notice that you are probably also missing some % for the Primary_Zip term.)
  18. to allow for both the possibility of adding a new or removing an existing course entry for an organization, you should probably use a set of radio buttons for each choice. your form should submit the org_id, course_id, and if the course should be added or removed for that org_id. you would then remove any existing rows that have been selected for removal (the remove radio button was picked) and add any new rows that have been selected to be added (the add radio button was picked.) trying to delete rows that don't exist won't hurt anything and trying to insert duplicate rows, using the IGNORE keyword in the query, also won't hurt anything, so your logic doesn't need to try to determine which data has been changed, it can simply delete/insert whatever the submitted form data says to do. i would set up the radio buttons with a two dimensional array name in the html, with the org_id value as the index for the first dimension and the course_id as the index for the second dimension. there would be two radio buttons with the same array index values, one radio button would have the value 'add' and the second would have the value 'remove'. you would pre-select the 'add' radio button based on if there is already a row in the database table and pre-select the 'remove' radio button if there is not already a row in the database table. initially, with no data in the database table, all the remove radio buttons would be selected. an example of what the browser would show -
  19. a) you can use an ip address in a url (a domain name in a url is resolved to it's ip address by the requesting client anyways and http/ftp requests are actually performed using the ip address.) b) the ip address you have listed is the local network ip of your computer. it's not the public ip address, which would be the ip address of your dsl/cable modem/router. in order to make your computer on your local network accessible over the internet, you would need to set up port forwarding on your router. why exactly are you trying to do this, since most isp's don't allow public servers to setup on their networks?
  20. the following methods for inserting bulk data, are from most to least efficient - 1) use a LOAD DATA [LOCAL] INFILE query. 2) use a multi-value INSERT query, with as many rows as possible in one query. the length of each query is limited by the max_allowed_packet mysql setting, default 1M bytes, which can be changed, but the default should allow you to insert at least 1000 rows in each query. 3) use a prepared query in a loop. this is only slightly more efficient then method #4, since the data for each query must still be communicated to the database server and it's the hand-shaking and communications between php and the database server where most of the time is spent (queries and data are sent as character strings.) 4) use a non-prepared query in a loop. this is likely what you are doing now. turning off indexes, auto-commits, and unique constraints on the tables will also speed up the process, see the following link - http://dev.mysql.com/doc/refman/5.6/en/insert-speed.html
  21. exactly which part are you not clear on? creating the table or inserting the data? and what have you tried, for we cannot help you unless you have something that you have tried to do that didn't work the way you expected it to.
  22. you need a third table to do this correctly. your organization table should just contain the unique information about each organization. your course table should just contain the unique information about each course. the third table that relates them would have columns for an id, org_id, and course_id. the org_id and course_id columns should also be setup as a unique composite index to prevent duplicate org_id/course_id entries.
  23. sorry, but we don't answer exam questions for you. your instructor is testing your knowledge and ability to do the work, not our's.
  24. your excel layout is rather unique, so you are going to need to write some unique and specific code to import the data. exporting your excel spreadsheet as a csv file and using php's csv file functions would result in the simplest code. you would need to read and store the first row of dates from the file, then loop over the actual rows of data and loop over each pair of start/end times in a row and access the corresponding date from the previously read first row to produce the datetime values. edit: the following should get you started, however, the fun in programming is when you devise, write, and test your own code that produces the result you want - $file = 'a.csv'; // the name of the csv file $row = 1; // used to identify the rows with the dates and the actual data if (($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 0, ",")) !== FALSE) { if($row == 1){ // get the first row of dates $dates = $data; } if($row >= 3){ // the actual data // data[1/2], [3/4], [5/6], ... corresponds to dates[1], [3], [5], ... $id = $data[0]; $num = count($data); for($x = 1; $x <$num; $x=$x+2){ if($data[$x] != ''){ // there's a time entered $date = new DateTime(str_replace('/','-',$dates[$x])); // UK date format $dt = $date->format('Y-m-d'); // convert date to YYYY-MM-DD $start = $dt . ' ' . $data[$x] . ':00'; // YYYY-MM-DD HH:MM:SS format $end = $dt . ' ' . $data[$x+1] . ':00'; echo "ID: $id Start: $start End: $end<br>"; // display the result } } } $row++; } fclose($handle); } else { echo "could not open file: $file"; }
  25. where in your add user code are you setting $password from the $_POST variable? when you echo the two hashes and the salt in the log in code, is the salt the correct length and are the hashes completely different or do they start out the same, but the one from the database is missing characters on the end? edit: also, why are you looping the in the log in code. you should have at most only one row for each user.
×
×
  • 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.