Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,450
  • Joined

  • Days Won

    175

Everything posted by mac_gyver

  1. the $values[] = " ... " statement would be - $values[] = "('$RemedyTicketNo[$index]','$PhoneNumber[$index]','$Createdate[$index]', '$Category2','$Category3','$Status','$Date','$Severity','$BanType','$XiD')"; the corresponding $sql = " ... "; statement would be - $sql="INSERT into tbl_main (ars_no,phone_number,create_date,category_1,category_2,status,resolved_date,trouble_type_priority,ban_type,employee_id_name) VALUES " . implode (',',$values);
  2. i'll bet the error changed to - Access denied for user 'root'@'localhost' (using password: NO). that's not the same error you were getting before (yes it matters if the username in the error changed or not.) if the message didn't change to that, then your script is not using the correct config file. did you create the aqw database first? the root user should automatically have access to any database that exists and if you are doing this for a real site, you should not use the root user, but create a specific database username with a password to use.
  3. your script is likely turning display_errors back on. find and remove any ini_set statements for the display_errors setting. the only time error_reporting/display_errors statements should be in a script are for temporary debugging purposes. you should be able to set and leave error_reporting at E_ALL in your php.ini.
  4. a multi-value/multi-row insert query's syntax is - insert into table_name (column_a, column_b, column_c, column_d,...) values ('value1_a', 'value1_b', 'value1_c', 'value1_d',...),('value2_a', 'value2_b', 'value2_c', 'value2_d',...), ... the order of the column names and the values must match. if you list the phone_number column as the second column, the phone number data must be the second value in each set. you need to build the complete ('value1_a', 'value1_b', 'value1_c', 'value2_d',...) string, with a value for every column listed in the query, when you assign the data to $values[] = " ... ";
  5. you would need to start by defining how you want multiple sets of data to be inserted (you cannot write any code to do what you want if you don't know what you want the result to look like). do you want one row for each set of data (the way you should be storing data) or are you trying to store the values from multiple sets of data in one row (which is not the way you should storing data.)
  6. actually, do a SELECT * FROM `users` WHERE `email`='email@gmail.com' and post what you get as a result so that we can see it too (alter the posted email address if it is a real one), to help in finding out why what you are doing isn't working. posting your table definition and your actual code that is forming and running the query would help too. you either have one or more rows with that email address in it and have a row with an empty password in it that the query is directly matching or you have a row with a password value containing characters in it that are being converted to a value so that it matches an empty string. it's also possible that both your actual code and the method you are using to run the query directly in mysql (you haven't shown your code or stated how you are directly running the query) is causing a conversion that matches a row (see the following thread where someone was matching all values in a column because of a character column being treated as/converted to a number for the comparison - http://forums.phpfreaks.com/topic/276881-mysqli-update-using-placeholders/ ) to help you to find the cause of the problem we need to know and have all the information, code, data, that you have about the the problem.
  7. here's an example of just the right amount (not too much and not too little) of code you need to do this - // make a list of the links (expected values) $links = array_merge(array('0-9'),range('a','z')); // produce the links echo "Click link to search by: "; foreach($links as $value){ echo "<a href = '?search=$value'>".strtoupper($value)."</a> "; } echo "<br>"; // condition and validate the search value $search = isset($_GET['search']) ? strtolower(trim($_GET['search'])) : ''; if(!in_array($search,$links)){ // supplied search term is not an expected value $search = ''; } // use the search value if(empty($search)){ // nothing selected echo "Please select something to search for.<br>"; } else { // perform the search echo "You searched for $search.<br>"; if($search == '0-9'){ // special handling for a 0-9 leading wild-card search $query = "SELECT * FROM `content` WHERE `title` REGEXP '^[0-9]' LIMIT 0 , 30"; } else { $query = "SELECT * FROM `content` WHERE `title` LIKE '$search%' LIMIT 0 , 30"; } echo $query; // run the query, check for errors, check if any rows found ('No matching row(s)' message if none), display result }
  8. you are kind of missing the point of variables. you don't create a variable for each possible value, you create one variable, with a name that indicates the purpose of the data in the variable, that can hold any of the possible values. you are creating 27 times too much code (well at least 26.5 times too much because your 0-9 number range requires a little special handling to form a query that will match the range of leading numbers.) your $_GET variable should be something like $_GET['choice'] or $_GET['category'] or $_GET['search']... all you would do is then validate that it contains an expected choice, then use it in one single query statement (not a hard-coded and separate query statement for each possible choice.) as to why nothing was output when you tried your code, there's several possible reasons, but your code isn't readable as posted in the thread and until you have just the code you need with one variable and one query using that variable in it, not too may people are going to wade through your code.
  9. how do you know you are matching a row/getting the ID when the entered password is blank?
  10. the change log can be examined for specific things that have been fixed or added since any particular starting version - http://php.net/ChangeLog-5.php
  11. you can do anything you want in a programming language if it produces the result you want. the creative part of programming is to get a computer to do what you want, where you want it to be at. if you want to display a message that there are no tickets left, you write the logic to test for that condition and produce the message you want at the point where you have that data available and at the point where you want that message to be output at.
  12. at least one of the versions of the code is running mysql_query() on the actual query, then running mysql_query() again on the result resource from the first mysql_query(). your original code didn't have the first mysql_query() statement and you randomly added it at some point for no reason.
  13. the errors are referring to the two $_POST variables. the form you posted apparently isn't the one that is submitting to that code and those two fields don't exist or are invalid html in the form.
  14. about the only way you could get that error from that sql statement is if you left the leading or trailing php single quote ' on it when you copied/pasted it into mysql to run it. the sql you posted doesn't produce that error for me when i tried it directly in mysql.
  15. a html comment is still content that is being sent to the browser. you must remove all characters being output to the browser that come before the session_start() statement.
  16. you would only run the sql part of that statement directly in mysql. the leading $q = ' ... and ending '; are php code, not sql.
  17. the first code you posted has a fatal php syntax error (you can see where it is at in the code because the syntax highlighting in your post stops changing colors.) you should set php's error_reporting to E_ALL and display_errors to on in your php.ini to get php to display all types of errors. time for some mysql basics. the following is the syntax prototype for a SELECT query (it and a lot of useful information can be found in the mysql documentation at - http://dev.mysql.com/doc/refman/5.5/en/index.html ). i have highlighted the part of the syntax that would get the result set in alphabetical order (the default is ASC ascending) - SELECT [ALL | DISTINCT | DISTINCTROW ] [HIGH_PRIORITY] [sTRAIGHT_JOIN] [sql_SMALL_RESULT] [sql_BIG_RESULT] [sql_BUFFER_RESULT] [sql_CACHE | SQL_NO_CACHE] [sql_CALC_FOUND_ROWS] select_expr [, select_expr ...] [FROM table_references [WHERE where_condition] [GROUP BY {col_name | expr | position} [ASC | DESC], ... [WITH ROLLUP]] [HAVING where_condition] [ORDER BY {col_name | expr | position} [ASC | DESC], ...] [LIMIT {[offset,] row_count | row_count OFFSET offset}] [PROCEDURE procedure_name(argument_list)] [iNTO OUTFILE 'file_name' [CHARACTER SET charset_name] export_options | INTO DUMPFILE 'file_name' | INTO var_name [, var_name]] [FOR UPDATE | LOCK IN SHARE MODE]]
  18. you would use recursion to process any arbitrary number of parent/child levels. retrieve all the data into an array with the main index being the parent's id. the order of the data at any parent's id level would be the order that is it displayed as (see main index 0 and 4 entries in the following example.) // makeup some data (your code would get the data from wherever it is stored at) // id=>x is each item's id. menu=>'string' would be your menu display text $menu = array(); $menu[0][] = array('id'=>2,'menu'=>'main menu, w/children'); $menu[0][] = array('id'=>1,'menu'=>'main menu, no children'); $menu[2][] = array('id'=>3,'menu'=>'sub-menu'); $menu[4][] = array('id'=>5,'menu'=>'sub-menu1'); $menu[4][] = array('id'=>8,'menu'=>'sub-menu2'); $menu[0][] = array('id'=>4,'menu'=>'main menu, w/children w/children'); $menu[5][] = array('id'=>6,'menu'=>'sub-sub-menu'); $menu[6][] = array('id'=>7,'menu'=>'sub-sub-sub-menu'); function recursive_display(&$arr, $parent, $indent=0){ // if some of this function code looks familiar to anyone here, it was found here on phpfreaks $ind = $indent * 30; if (isset($arr[$parent])) foreach($arr[$parent] as $rec){ echo "<div style='width:500px; margin-top:5px; margin-left: {$ind}px; padding:5px; border:1px solid gray;'> ID: {$rec['id']} - " . (($parent) ? "Sub-menu for: $parent - " : '') . "Produce link here for: {$rec['menu']} </div>"; recursive_display($arr, $rec['id'], $indent+1); } } // call the recursive display function recursive_display($menu, 0);
  19. it would take seeing the code that reproduces the problem to help you. a copy/paste of the 'view source' of the incorrect output would help too. do you have any javascript/jquery on the page that could be altering the textarea? edit: i'm going to guess that your <textarea> </textarea> tags have the tabs between them in your source code and when you output actual data they are after the data and get trimmed off or otherwise ignored.
  20. you need to debug to find out what exactly is happening. does the form/page not submit at all or it is submitting but the data isn't what is expected or it submits the expected data but that data isn't being used. what debugging have you done?
  21. if($v['tickets_left'] > 0){ ... code when there are tickets left ... // you already have this } else { // add this, right after the closing } of the existing if(){} statement ... code when there are no tickets left ... }
  22. the line if (count($venues) == 0) { being true means that there are no venues found/defined/entered in the database, not that there are no tickets available for any specific venue. as you loop over each venue's data starting with the line foreach ($venues as $v) {, you would test the $v['tickets_left'] value and output whatever it is you want for the case where there are and are not any tickets left. since the code is already testing if ($v['tickets_left'] > 0) { ... code when there are tickets left ... } if what you are asking is to output a message when there are no tickets left, just an an else { ... code when there are no tickets left... } statement on the end of that if(){} statement.
  23. how do you know that it works? do you have a working system that you just need to get the table definitions for? if so, you can use a SHOW CREATE TABLE table_name query. did you not try to do this yourself? it's pretty straight-forward. find the queries, make a list of the fields for each database table, either used directly in a query or in the data fields fetched from a query, and determine the datatype of each field.
  24. the session handler class has nothing to do with the subject of this thread.
  25. the number of rows you display per page should be a variable, so that it will be the same value in the three places you are using it. your code is using 20 in one place, and 50 in the other two places.
×
×
  • 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.