-
Posts
5,449 -
Joined
-
Days Won
174
Everything posted by mac_gyver
-
sorry to be blunt, but the code you have posted looks like it was just copy/pasted together from three or more different sources, without any planned goal or purpose. some if it is not even valid php code, nor is the statement referencing the .mwb file how you access a database. there's even a link in the form that indicates you are running this directly from your desktop and not through a server (php is a server-side scripting language and requires a web server. you can install all-in-one wamp package on your computer to allow you develop php code locally.) so, you need to slow down and go back and learn the basics, both for what you are tying to do, develop a web page (i.e. how a web server and a browser work) and to learn enough php so that you can write valid php code. then you can read through tutorials (or even just the examples in the php.net documentation) showing how you make a database connection and form and run a sql query statement. then you need to read through some tutorials that show php form processing so that you can get the data from your form into your sql query statement.
- 3 replies
-
- php
- registration
-
(and 2 more)
Tagged with:
-
your lack of time to learn the basics isn't our problem. for the basics, you need to spend your time and maybe some money to buy and read a book, take a class, hire a tutor, or study enough online tutorials to learn the prerequisite information for the task you are trying to accomplish. programming help forums are for people to get help with code they have written. if you are not at the point where you can even get past simple punctuation and language errors in any code and are just posting error after error you are getting in some code you have found, you are not at the point to even be asking for help in a programming forum, because you haven't programmed anything. you need to either a) learn enough of the programming language you are using so that you don't need to be spoon fed in post after post, or b) hire someone to write the code that does what you want. and finally, since this is some third party code and not your own, moving this thread to the Third Party Script Forum Section...
-
i'm going to guess you are not seeing any php errors because you are not requesting the page with a ?status=n on the url and most of the logic is being skipped over. you might also have output_buffering turned on in your php.ini and any output from php or your code is being discard. btw - to toggle a value between back and forth between zero and one, you don't need all that logic - include 'db.php'; $mysqli = new mysqli($mysql_hostname, $mysql_user, $mysql_password, $mysql_database); if($mysqli->connect_error){ die("Connect Error ($mysqli->connect_errno) $mysqli->connect_error"); } $status = isset($_GET['status']) ? (int)$_GET['status'] : false; if($status) { if(!$mysqli->query("UPDATE product set status = NOT status where product_id=$status")){ die("Query failed: $mysqli->error"); } header("Location:item.php"); }
-
all your basic mysql questions are answered here - http://dev.mysql.com/doc/refman/5.6/en/index.html
-
PHP form pull MySQL data for field when another field is selected
mac_gyver replied to tycoonbob's topic in PHP Coding Help
@JIXO, while it's true that the external data being put into the query needs to be escaped, the current problem is because names containing html special characters are being echoed out in the html and the special characters are breaking the html. only a portion of the value is being submitted because of this. another point, the value =' ... ' attribute should be the row id that corresponds to the name. this will result in the least amount of data being submitted and will result in the fastest sql query. -
obviously the author of that site didn't write/test this code and you should not waste any more time trying to use it unless you are trying to gain experience debugging php syntax errors. its not this forum's function to debug a bunch of syntax errors in code that was found on the Internet.
-
the category class definition is incorrect. it should start with - <?php class Category {
-
yes, but you haven't told us what the debugging echo/print_r statements showed. for all we know the glob() isn't finding any files because the path, filename, letter-case, or date format isn't correct.
-
Issue with readfile() and download on at least one mobile browser
mac_gyver replied to LLLLLLL's topic in PHP Coding Help
because it is highly likely that it's your force download code where the problem is at. if you look at the questions in any programming help forum, 99.5% of the time, the problem is due to a lack of or a misinterpretation of the core information. the other .5% are due to actual bugs in the underlying system. at this point, since you don't know yourself, don't believe that it could be your code causing the problem, we cannot help you further without specific information that you have refused to simply post, bye. -
the $cart object apparently contains the content/items in the cart. the basket object also contains an $items property that isn't used, at least within the posted code (whoever wrote this code didn't do a very good job.) since the code is already looping over the contents of the $cart object, at about line 65, you should build the information you want to put into the email into a php variable within that loop, then simply put that php variable into your mail code later.
-
PHP form pull MySQL data for field when another field is selected
mac_gyver replied to tycoonbob's topic in PHP Coding Help
in general, any text content that you output on a html page, that could contain any html special characters in the content, should be passed through htmlspecialchars() when it is output, with the second parameter set to ENT_QUOTES, so that any html special characters in it won't break the html markup on the page. -
posting the error message, with the line number mentioned in it, would allow someone to help you. as it is, all you are have done is dump your code on a forum and that won't get you much help since we don't have the slightest idea what you saw in front of you that would narrow down the problem.
-
Proper method for form & function with variable validation
mac_gyver replied to airborne305's topic in PHP Coding Help
you must get your form and your form processing code to work at all, first, before you can add something like using AJAX to submit data without refreshing the page, because even with AJAX, the only thing the client side code can do is make a http request to the server side code, so the same functionality and same root code must exist regardless of using AJAX or not. here's a little http client/server 101. the client side code cannot directly call functions in or set variables in the server side code. all it can do is make a get or post http request to the server side code. it is then up to the server side code to have logic that looks at the $_GET or $_POST variables it receives as input and decides what to do with them. -
Issue with readfile() and download on at least one mobile browser
mac_gyver replied to LLLLLLL's topic in PHP Coding Help
since you are redirecting around all over the place based on conditions, it's likely you have some combination of a logic error/value problem/redirect loop/trying to use $_SERVER['HTTP_REFERER'] (which you cannot rely on) and/or don't have an exit statement after one or more header redirects. here's my current guess - your logic is trying to redirect back to a page (you would like it to be the original download page) via a value either from a session variable or HTTP_REFERER, for some condition such as the requested file cannot be found, and your logic has already set the session variable that states a download has already occurred, but for the devices where this doesn't work, the url being used in the redirect ends up being to the force download script (i.e. the session variable or HTTP_REFERER value being used as the target page is likely empty so that the redirect is to the current page, which is the force download script), but it now has a get parameter on the end of the url, not of the filename to download, but the url of the download page, resulting in the original download page being requested (and since the session variable stating the download has already been used, is set, the content on that page shows that message) and the url of the original download page is read and output as the content of the forced downloaded file. some problem with just posting your code? it would save a bunch of time and cut out the guesswork. of course, if what i have theorized is actually happening, it means your force download script is not validating the supplied filename and your script will allow any file on the server to be requested and downloaded, such as the file holding your database connection details. -
also, the date math isn't doing what you expect. by only modifying the month, trying to go back past the start of the year, will try to find dates in the future. use this - EXTRACT(YEAR_MONTH FROM checkout_date) = EXTRACT(YEAR_MONTH FROM CURRENT_DATE - INTERVAL $month_skip_number MONTH)
-
wherever you copy/pasted your post from dropped the newlines. i recommend that you post your original content, question and code, putting your code in the forum's bbcode tags (the edit form's <> button), so that someone will even attempt to look at your problem.
-
Issue with readfile() and download on at least one mobile browser
mac_gyver replied to LLLLLLL's topic in PHP Coding Help
it doesn't matter how many servers or browsers your code may have worked on, what matters is what is exactly happening on the one server with the client(s) where it doesn't work and with the files or file types where it doesn't work. this is something going on, on the server. that means everything from the request it receives from the client, through all the code/settings involved, to the last byte of data that is send back at the end of the download. without seeing what the http request(s) are in the server's access log file (you may be getting multiple ones from the client), what sort of url rewriting there might intentionally or accidentally be, what your full php force download code is (less any database credentials), what values the code is actually using when it doesn't work (they may have looked correct and normal to you, but they would provide a clue to someone here, such as how the server could be sending the html contents of a page when it should be sending the contents of a file stored somewhere), ... there's no way to eliminate anything on the server as the possible cause of the problem. when you opened the 14k file in your editor and saw the html of the download page, were there any php errors at the start or end of it? do you have php's error_reporting set to E_ALL and either display_errors set to ON or log_errors set to ON so that you would know if there are any php detected errors? have you looked at the web server's access log to see what the requests are? is there only the one expected request to your force download script or are the more than one from the client? have you looked at the web server's error log to see if there is any relevant information in it? and since this may have something to do with php's output buffering, what does the output from a phpinfo() statement show for the output_buffering setting? are you intentionally or perhaps accidentally using any sort of output handlers/call-back functions? edit: i would also be logging the integer length that the readfile() statement returns. -
what have you done to debug what your code and data are doing? is the form submitting data with the correct key/value that you expect? showing us what the form data is, would help someone to attempt to help.
-
Issue with readfile() and download on at least one mobile browser
mac_gyver replied to LLLLLLL's topic in PHP Coding Help
what's your complete force download script? best guess is the $filename variable is being set to the page the download link was on, perhaps due to some url rewriting or similar. also, afaik "application/force-download" is a non-existent type and cause browsers to perform a raw/binary download because the browsers don't know what to do for a non-existent type. afaik, the content type for a file download should be application/octet-stream This may also have something to do with the devices where this isn't working as they may be choosing to do something different for a type they don't understand. edit: at this point, i would be logging the actual data your download script is receiving as input values so that you can look to see if the problem is in the values it is receiving or in something after the code runs. -
Attempt to assign property of non-object
mac_gyver replied to littlewing1977's topic in Applications
you could always test this since you have a working system installed. -
Attempt to assign property of non-object
mac_gyver replied to littlewing1977's topic in Applications
i suggested commenting out the three lines that are setting $options variable from the inline mysql query code. the rest of the code on that page expects $options to be an instance of the options class. therefore, any code that is directly setting $options to anything else, doesn't belong. -
Attempt to assign property of non-object
mac_gyver replied to littlewing1977's topic in Applications
ASSUMING (<--- making a big assumption) that the options class functions correctly, i.e. getting the global settings, then modifying them with any user settings, then the offending mysql logic in the search.php page should not be needed. try it with the following lines commented out - //$options = mysql_fetch_array(mysql_query("SELECT displayAsPopup FROM " . TABLE_OPTIONS . " LIMIT 1", $db_link)) // or die(reportScriptError("Unable to retrieve options.")); // $options->displayAsPopup = $options['displayAsPopup']; -
Attempt to assign property of non-object
mac_gyver replied to littlewing1977's topic in Applications
if the posted lines of code are from multiple separate places in the program, they could be the intended usage. it may also be that the code has always been foo-bar and with warning messages turned off 'functioned' as the author intended. post at least 5-10 lines of code leading up to and including the line where the error is occurring. also, posting a link to the original site where you got this script would help.