-
Posts
5,449 -
Joined
-
Days Won
174
Everything posted by mac_gyver
-
Issue with readfile() and download on at least one mobile browser
mac_gyver replied to LLLLLLL's topic in PHP Coding Help
by opening the full correct file in a programming editor too, to see if the start of the file is the same. edit: also, did you scroll to the end of the 14k file when you had it open in your programing editor to see if there were any error messages at the end of it? -
Issue with readfile() and download on at least one mobile browser
mac_gyver replied to LLLLLLL's topic in PHP Coding Help
when you open this 14k file after it has been downloaded, in a programming editor, what does it contain? is it the correct first 14k of the actual file or is it some error messages from the server? -
My SQL Insert into Sometimes working and sometimes not
mac_gyver replied to durgaprasadcs's topic in MySQL Help
two possibilities come to mind - 1) you have some indexes/unique keys set up and you are tying to insert duplicate values. 2) you are not escaping the string data being put into the query and some data contains sql special characters. -
also, any 2nd though last parameters of the session_set_cookie_params() statement need to be identical for all calls to that statement to insure you are starting/resuming the same session.
-
@nisroc, this forum section - PHP Regex is not for general php questions. this is the third recent post you have made in this section. you will get more, faster, better replies to your php questions in the PHP Coding Help forum. moving this thread for you...
-
sounds like your logic on the page is producing the dropdown before the logic that is deleting the rows in the database table. code on a page should be organized with any action/processing first, then produce and output any content. if that doesn't sound like what is causing the problem, you would need to post your code.
-
the page you are redirecting to is likely redirecting back to the first page or it's all the same page. this indicates two possible problems - 1) you have a logic error. i.e. your program logic shouldn't be redirecting under some conditions and the conditions you are testing are incorrect or don't exist at all. 2) you need to have an exit; statement after header() redirects to prevent the rest of the code on the page from running.
-
one of the problems with trying to develop code using a live server is you must make sure that the code you wrote actually made it onto the live server and is the code that is actually running and producing the result/symptom you are observing. a forum like this sees a fair number of posts like - 'my code is doing something different today/now, then it did yesterday/the last time I tried it'. we also regularly see posted code that cannot possibly be producing the errors/symptoms that are being reported. this is often due to the code in your programming editor being different from the code that is actually running on the server, because of (pick one) - a) the code wasn't saved at all or to where you intended or there are multiple versions in different locations..., b) you or your editor didn't upload the code to the server or in the correct location on the server, c) the upload of the code failed and the error message to that effect was not noticed. by using a localhost development system, the files are edited in-place and as long as you save your file when you close your editor (and you don't have a mess with same name files scattered throughout multiple folders in your project) you will know that the code that is running is the code you last saw in your programming editor.
-
using a session variable as the means of passing data between scripts won't work unless the script updating the value into the session variable executes a session_write_close() after every update and then executes a new session_start() to resume the session. modifying a $_SESSION variable while a scripting is running, only changes the value of that variable in memory. it isn't actually stored in to the session data file (where a different script could get the value of it) until the first script ends or you use a session_write_close() statement.
-
that's too vague. there could be a half-dozen different reasons for that symptom. it would take knowing what the code is, to know how it is supposed to be accomplishing the task, to pin down what the problem is. best guess, your code is dependent on a very old php setting (turned off 11 years ago) that is no longer even present in current versions of php. how do you even know this is a database problem or that the database isn't connecting?
-
that's not 100% correct. as it is, that's valid syntax. adding the single-quotes will produce a php syntax error. if you need to put an associative array variable into a string, it's best to tell php where it starts and end by putting {} around it - ('{$_POST['fname']}','{$_POST['lname']}') when i took a look at your .php page (the url you posted with the .html is 404), there's a mysql_connect error message (perhaps it is hidden by the iframe popup your host is outputting.) unfortunately, this error message is exposing a bunch of information about your account/database username. you should be learning php on a localhost development system and only put your code onto a live server after it is completely working and with no php settings or code that exposes any of your account information when an error occurs (hackers intentionally trigger errors to get this type of info.)
-
the file extension should be .php (anything else requires that you take a specific action to configure your server to work with php.) when the file name ends in a .php, and the form action=' ... ' attribute is changed to match, what did occur in front of you when you submitted the form? did you get the "1 record added" message or what? what URL are you using in your browser to request the page? if this is on a local development system, it should be something like http://localhost/your_file_name.php lastly, the 4th parameter of the mysql_connect() statement is not something you usually supply. it is a flag that forces a new connection.
-
run function from class on mysql array results
mac_gyver replied to will35010's topic in PHP Coding Help
the only thing that is apparent from the code you posted is that your $TrackingClass->GetPriority() method likely (only you know for sure) returns a mysqli result object and you are trying to echo that. wouldn't you need to to fetch a row from that result set, then access a specific element of that row before you could echo its value? or even better, wouldn't a method named GetPriority() do all the necessary work internally and just return the priority value? -
to reuse code, you would write a general purpose function or class method that accepts the input values, runs the necessary code, and returns the expected result back to the calling program. in those cases where you tried something and got errors, you would need to post the code and the error to get help.
-
if i remember correctly, you want to pre-select the option for the currently displayed record. seems that is what this previous post did - http://forums.phpfreaks.com/topic/284692-populate-an-arrayed-dropdown-when-clicked/ you would form the option list in a php variable before the start of the heredoc statement and just put the php variable in at the correct point.
-
Could PHP pass images via ajax to javascript?
mac_gyver replied to D.Rattansingh's topic in PHP Coding Help
in general, browsers directly request the images that are displayed on a page via the url of that image. you can use javascript/ajax to write/update the html on a page that would then cause an image to be displayed/refreshed. the image itself can be dynamically produced and output by php on the server. there would be no need for actual ajax to do this (making an async http request to get changing html from the server), just use javascript to 'write' the <img src url into the DOM of the page to get the browser to request the image from the server. do you have a more detailed statement or example of what you are trying to accomplish? -
Check whether values from array exist in column...
mac_gyver replied to Kristoff1875's topic in MySQL Help
a little bit off topic, but your $_POST['Selected']; // eg "Box1,Box2,Box3" value indicates your user interface requires someone to either type or copy/paste a list of choices or you have a bunch of code to produce that list from whatever is being selected by the user. what you should have are checkboxes, using an array name for the form field, so that all the user needs to do is check the box(es) they want and submit the form. unavailable boxes would either not be shown at all or would be shown as disabled when you dynamically produce the form based on the possible choices and the choices already picked. -
looking for a good OOP MYSQLI class with docblocks
mac_gyver replied to rbrown's topic in MySQL Help
since php has a build-in mysqli OOP class, what exactly do you need that the built-in class doesn't do directly or that you cannot extend it to do? you haven't exactly stated any specific functional needs. -
the cause of the current error is exactly the same reason as the previous error, no white-space where some is needed so that the sql parser can distinguish between different elements in your query. i recommend that you NOT form php strings, in this case your sql query statement, by concatenating several different lines together. this method of forming strings usually causes php/sql errors because of the switching back/forth between different contexts. all the syntax gets in the way of what you are actually trying to accomplish. just form strings using one context. the following is perfectly valid and less error prone - $sql = "SELECT status_id FROM status_grumble WHERE sub_category_id = $subcat ORDER BY status_id DESC LIMIT 10"; some notes about the above - 1) when php variables are inside of an overall double-quoted php string, they are replaced with their values. there's no need to close a string, put a php variable, open/start the string again. for associative array variables, i.e. $some_array['some_index'], you need to surround the variable with {} to tell php where it ends and starts inside the string. 2) in addition to the new-lines at the end of the first two lines in that string that are formatting the visual appearance in the program editor, there are at least one space/tab before the WHERE and ORDER keywords that both format the visual appearance in the program editor and separate them from the element that comes before them.
-
Check whether values from array exist in column...
mac_gyver replied to Kristoff1875's topic in MySQL Help
each piece of data, i.e. one box number, would be stored in one row in your database table. 5000 pieces of data = 5000 rows in the table holding that data. you can enforce uniqueness by assigning a unique key to the column holding the data. any attempt to insert or update the data to a value already in use would produce a query error. the table would have id, box_number columns. -
Unable to get error message from move_uploaded_file
mac_gyver replied to LLLLLLL's topic in PHP Coding Help
the recommendation is to use $_SERVER['REQUEST_METHOD'] == "POST" to detect if an upload form has been submitted. then, if the $_FILES array is empty, the file size likely has exceeded the post max size setting. you can further check the $_SERVER['CONTENT_LENGTH'] value and do your own comparisons with the maximum size settings to output your own user message.- 4 replies
-
- php
- move_uploaded_file
-
(and 1 more)
Tagged with:
-
i would get it working without ajax first (the server side code will contain the same functionally with/without ajax), then research - jquery ajax php populate dynamic select from database. for the non-ajax version, just use an onchange event for the first select to submit the form containing the selects. the server-side form processing page would use the submitted pickup location to query for the possible destinations, retrieve the result from the query and output the <option></option> entries. for the non-ajax version, you would echo these in the <select></select> menu tags. for the ajax version, echoing them would send them back to the brower as the response to the ajax request and the ajax response code would place them into the .html() of the <select></select> menu already on the page.
-
here is a 'test' that shows why you wouldn't write code with functions (or variables) named after specific categories/manufactures/brands.... - to add, remove, or change a category/manufacturer/brand..., you should not find yourself writing or editing program logic. your program logic should be general purpose so that it can operate on any number of categories/manufactures/brands simply by defining the necessary 'data' entries somewhere (database tables, arrays, xml, serialized/json data.) i'm betting the only thing your named hard-coded functions are doing differently between them is in the data values that are being assigned? if so, you have taken a data driven design and hard-coded it into your program so that it now requires a "programmer" to perform a simple operation like adding a new brand or changing one of the values. this will get you escorted out the door in a real business. anyone (authorized to do so) should be able to add/change categories/manufactures/brands through a user interface that modifies stored data values, not by adding/modifying functions in the code.
-
OR you could just integrate your login form/form processing code on any page that needs it and avoid the need to remember where to return to after a successful login.