-
Posts
5,449 -
Joined
-
Days Won
174
Everything posted by mac_gyver
-
before you can attempt to fix a problem, you must find out what the cause of the problem is. everything you have mentioned won't help much if the page(s) themselves are outputting huge image/media files. caching could help with dynamically produced images, where any one image is reused. what is the amount of html markup on a typical page and what is the total size of the image/media data? where are the images stored at (file system or in a database table)? are images dynamically being produces/manipulated?
-
there will be an error for that condition because the code is testing if the query failed.
-
at this point, i don't think we can help you with this basic/common task. you are not following through completely on the things that have been suggested and you have in fact removed the debugging code already put in. until you get this to work, you are not done debugging it and leaving in those various echo statements would provide important feedback. they would even indicate that php's error_reporting/display_errors settings are actually working, which they are not, despite you being asked to confirm three different php.ini settings.
-
the http 500 error is because you have a php (syntax) error in your code. in a previous thread, it was suggested to turn on php's error_reporting/display_errors (to get php to help you.) the reason no one replied when you asked what/how to do that is because the suggestion is a common activity that you are expected to search for the answer yourself, not just immediately ask without trying. if you look at your posted code at the start of this thread, you will notice that the forum software has color coded the different contexts it found and the php if() ... code has the same color highlighting as the php string, meaning your php string isn't terminated and is trying to make the php if()... code part of that string (your programming editor should have similar color highlighting to help you see differences/changes or lack of in the context of the code.) you need to go back and reread post #2 as many times as necessary until you understand what was stated and what the code is doing. it both corrected the string syntax and it performs the logic that your code needs. you could also test the code that was given to see what it actually does for the range of $band['rating'] input values.
-
in my list of suggestions, was one to actually check what the error_reporting/display_errors/output_buffering settings are using a phpinfo() statement. just because you saw some setting in a php.ini does not mean that php is actually using that file or using those settings. in programming, you must actually confirm that the computer is doing what you want.
-
since the current code doesn't contain any of the previous debugging statements, some possibilities - 1) your code is doing what you expect, but the header() statement is either failing (there would be a php error if error reporting is turned on) or you have code at the welcome.php page that is redirecting back to the form. 2) you may have output_buffering turned on in your php.ini and anything you or php have tried to output on that page has been discarded when the redirect occurs. 3) your code isn't matching the username/password (perhaps the password has been hashed when stored into the table) and you have no logic in your code to address this common occurrence. for items #1 and #2, in your php.ini, set error_reporting to E_ALL, display_errors to ON, and output_buffering to OFF. you will need to restart your web server to get any changes made to the php.ini to take effect and confirm that these settings actually have been changed by looking at the output from a phpinfo() statement. also, for the time being, comment out the header() statement and put in an echo 'you have successfully logged in'; statement so that you know precisely what the code is doing. for item #3, when validating user input (in this case authenticating the username/password), you ALWAYS need an else{} statement to tell the user why his input failed the validation test. if there isn't a matching username/password, inform the user of this by outputting a message. lastly, when the username/password does match a record in the table, you should be retrieving the user's id and setting it into a session variable so that you remember that the current user has been authenticated and who that user is.
-
you have stated the form isn't doing anything, apparently not going to the processlogin.php page AND you have echoed the $sql variable and it contains what you expect. both of those events cannot be occurring at the same time. what is your current form and current form processing code and please start posting any code from each file using the forum's bbcode tags (the edit form's <> button).
-
actually, i just determined why the code doesn't work. the kid who wrote it didn't have a clue, nor did he test the code, and his database class is storing the result set within the database object, rather than returning an instance of a result object, combined with trying to loop over the result from one query to get more query results. the offending code starts in the getTankObjects() function and the tank class and in the use of the database object. but given how bad just the code for this 'tanks' display is, do you really want to try and go through and fix everything else it is likely doing wrong?
-
that script is pretty bad. functions wrapping classes using globals, running queries only to run more queries inside of loops getting the same data the first query could have... start by debugging what data is in $tanks in the code you posted. what does the following show when added right before the foreach(){} loop - echo '<pre>'; var_dump($tanks); edit: see the following reply.
-
there's no way the given code, which i tested before posting, can produce the result you are listing.
-
by using the SUM() aggregate function, there will only be one row in the result set. there's no point in having the extra code needed to loop if you are fetching just one row.
-
What's wrong with my DB query (COUNT, UNION ALL, PDO)
mac_gyver replied to PHPBear's topic in PHP Coding Help
you have a problem that is preventing the query from working and once it works, a problem that is preventing the value you are fetching from working. 1) your code has no error checking logic in it to test if the query is working or not, then reporting the pdo/mysql error when it does not. if you did, you would be getting a somewhat vague but true-full error that would be calling your attention to the place-holder/bound statement - Error: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens. the reason for this error is the place-holder(s) being put into the query are not spelled/capitalized the same as in the bindParm() statement, i.e. the number of them don't match because the names being used don't match. 2) you don't have php's error_reporting set to E_ALL and display_errors set to ON so that a nonexistent variable reference would be reported. if you did, you would be getting an error at the $Total['num'] reference - Notice: Undefined index: num in your_file on line x this error is because the query as written doesn't select anything named 'num'. you would need to add an alias in the query statement. -
that's exactly what the code i posted does. if the result you got from that code isn't correct, that would mean that your posted data definition is inaccurate and it's impossible to write code without accurate information.
-
$classes = array_shift($values); // get the 1st array of class values $links = array_shift($values); // get the 2nd array of links // $values is just the remaining arrays of values at this point and can be repetitively looped over foreach($classes as $key=>$class){ foreach($values as $arr){ echo "<a href='$links[$key]' class='$class'>$arr[$key]</a><br>\n"; } }
-
the 500 server errors you have been getting (this and the last thread) are due to php fatal parse or runtime errors (there's no complete response back from the server.) you can get php to help you find what is causing the error by setting php's error_reporting setting to E_ALL and display_errors to ON in your php,ini file.
-
and, if you turn on exceptions after, or inside, your connection statement, the rest of the statements that fail will throw an exception that your try/catch block will use. in the current code, the ->exec() statement that is failing isn't throwing an exception so that you know it is failing - $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
How can API query be presented nicely on results page
mac_gyver replied to oracle765's topic in PHP Coding Help
you can do anything you want with the data (that's the point of programming, to get a general purpose computer to do what you want.) you can loop through the repeated data by using (untested) - foreach($json_arr['HotelListResponse']['HotelList']['HotelSummary'] as $arr){ // $arr will be an array of each hotel's data } the elements of the $arr array inside the above loop would be referenced like - $arr['name'], $arr['city'], ... you could either hard code the references or you could make an array of the element names, then just loop over that defining array and dynamically reference those element in the $arr array. -
the same result (using English Zodiac names), with only 25 lines of code - //determinar signo public function Determinar(){ $signs[] = array('start'=>'03-21','end'=>'04-20','sign'=>'Aries'); $signs[] = array('start'=>'04-21','end'=>'05-21','sign'=>'Taurus'); $signs[] = array('start'=>'05-22','end'=>'06-21','sign'=>'Gemini'); $signs[] = array('start'=>'06-22','end'=>'07-22','sign'=>'Cancer'); $signs[] = array('start'=>'07-23','end'=>'08-22','sign'=>'Leo'); $signs[] = array('start'=>'08-23','end'=>'09-23','sign'=>'Virgo'); $signs[] = array('start'=>'09-24','end'=>'10-23','sign'=>'Libra'); $signs[] = array('start'=>'10-24','end'=>'11-22','sign'=>'Scorpio'); $signs[] = array('start'=>'11-23','end'=>'12-21','sign'=>'Sagittarius'); $signs[] = array('start'=>'12-22','end'=>'12-31','sign'=>'Capricorn'); $signs[] = array('start'=>'01-01','end'=>'01-20','sign'=>'Capricorn'); $signs[] = array('start'=>'01-21','end'=>'02-19','sign'=>'Aquarius'); $signs[] = array('start'=>'02-20','end'=>'03-20','sign'=>'Pisces'); $date = sprintf("%02d-%02d",$this->month, $this->day); foreach($signs as $arr){ if($date >= $arr['start'] && $date <= $arr['end']){ $this->signo = $arr['sign']; break; } } }
-
i'm betting this is covered in the documentation. have you consulted the documentation?
-
Checkbox Form multiple tables export csv
mac_gyver replied to MyMammothTech's topic in PHP Coding Help
that's how RFQ (request for quotes) start, where you are planning on paying someone to do this for you. what is your code and the problem, symptom, or error you got for that code when you attempted to do this? -
because you code still contains an mail() statement - $sentmail = mail($to,$subject,$message,$header);
-
assuming this thread is related to your last one, where you have some application that you could not get to work directly with a mysql database, stringing together your application - ms sql - mysql IS NOT a proper way of getting this to work. you will end up with a solution that will be difficult to manage and maintain, with data that gets out of sync easily, and if this is for a real company that is expected to make money, could get you fired for even suggesting it, or if for a government project, will get you promoted.
-
you would need to ORDER BY total
-
without knowing what result you are getting and what result you expect, it's not really possible to help base on - "the data is still not correct" best guess is there should be no LIMIT clause as that would give just the row for the highest amount.
-
code in a browser cannot CALL a function on a server. the only thing that a browser can do is make a http request to the server, where the server-side code takes the submitted data (post, get, files, or cookie) and uses those values to perform some action. i recommend you read up on what ajax stands for and read some ajax/php examples.