-
Posts
5,450 -
Joined
-
Days Won
175
Everything posted by mac_gyver
-
you need to debug why your logic is producing the result that it is. this is the part of your conditional test that's causing that message - .. && $pass == $dbpassword start by using var_dump() on both of the hash values in $pass and in $dbpassword to see what they contain. one or the other could be empty (you have a logic error somewhere) or they could be mostly the same but different lengths (your database column isn't long enough to hold the value) or they could be completely different (the wrong password was used or your logic isn't the same when you stored the value and when you are comparing the value.)
-
if you show us your code, we could help you with it.
-
variables definitions have not changed in php since day one. the errors you are seeing were likely always present, but were being hidden by the error_reporting/display_errors settings where the code was being ran at. the undefined variable messages were explained in one of your previous threads, you are referencing a variable that doesn't yet exist. in the case of the += operator, you were shown how to define the variable before the start of the loop to prevent the error. for the Notice: Use of undefined constant meter_multiplier - assumed 'meter_multiplier' type of messages, that's because the code doesn't have the needed single quotes around the associate array index names, making php think you are using a defined constant as the index name, then when it doesn't find a defined constant by that name, it assumes you meant to supply a string, all taking up about 5 times more processing than if the code had been written correctly. both of these problems are because whoever originally wrote the code took short-cuts that saved a little typing (but was probably producing giga-byte size error log files.) the way to fix the errors is to do the work now that the original programmer left out of properly initializing variables and of putting quotes around things that are strings.
-
since we don't have any details about your selection conditions and what condition(s) in them you relax when there isn't enough matching data found, the only thing i can think of, to avoid running repeated sets of queries, is to select a large enough set of results in the first place, using the most relaxed set of conditions you are willing to use, then order the results by how closely they match the more strict conditions. this will give you a larger than needed pool data with an order/ranking assigned to each piece of data that you can use to find a result set that meets your needs.
-
or you could just normalize the data, storing each value in its own row in a database table and let the database do all the work when inserting, finding, or deleting any of data without needing a bunch of php code.
-
Help needed: SELECT specific user data from MySQL in PHP
mac_gyver replied to raneyron's topic in MySQL Help
actually, you should avoid doing that whenever possible. database code should be as general purpose as you can make it, without line after line of hard-coded logic and variables. the purpose of this block of code is to retrieve one record of information for a specific user. it's the higher-level calling code that knows about the database table/fields that are in the sql query statement and what data will be returned. the database code itself should just return the requested information in a generic form, i.e. the $row array that was fetched. -
you would actually do 'date-ination', where your links cause specific or next/previous dates to be selected, not logical page numbers. you can get a unique list of distinct dates and make a link for each one, displaying only the first one, a small range around the currently selected date, and the last one and/or you can make links with the currently selected date and a next/previous flag that would query for the next highest or lowest date from the selected date. if your dates can have a large number of results for any day, you may still want to have traditional pagination for the results. your links would just be built with the 'date-ination' selection and the logical page numbers for the pagination.
-
Help needed: SELECT specific user data from MySQL in PHP
mac_gyver replied to raneyron's topic in MySQL Help
the code you did post has two php syntax errors and the code never runs. one of the errors is in the for() loop syntax. you have the start of the alternate syntax using : but you don't have the corresponding endfor;, that if you do what Psycho has suggested of not looping to retrieve one row or using a while(){} loop, will likely go away. the second syntax error is a missing $ on the instance of your database connection, in $db, in this line - $result = db->query($query); //execute the query to get php to help you find syntax errors, you must have php's error_reporting set to E_ALL and display_errors set to ON in your php.ini on your development system. you cannot put the settings into your code and have them show you syntax errors because your code never runs to change the settings. -
Well this is strange and new. issue with & symbol and MySQL
mac_gyver replied to helloworld001's topic in PHP Coding Help
ginerjm, the url query string data format is one of the possible ways of supplying the data parameter in the .ajax() method. if you instead supply an object as the data parameter, of the form {key1: 'value1', key2: 'value2'}, it will be urlencoded by jquery when it converts the object internally to the query string format. -
Php errors wont load webpage
mac_gyver replied to LightWarrior's topic in PHP Installation and Configuration
the backup file you found is a database backup. that won't necessarily help you. how exactly are you changing the database password? i suspect you will need to perform a 'flush privileges' to get any changes to the database username/password to take effect. edit: i would create a small .php script with database connection logic in it, with connection error checking and reporting and get it to work first with the correct database and username/password before bothering with the SMF script. edit2: as to how your Settings.php file got cleared, one likely way is through the SMF software itself. you must always keep your software up to date with the latest patches/revisions. since this is opensource code and a popular script, it's easier to discover a security hole in it and then that information is quickly spread over the internet. -
also, for the mysqli database library, the port number is a separate parameter, not part of the host parameter.
-
Php errors wont load webpage
mac_gyver replied to LightWarrior's topic in PHP Installation and Configuration
because this was a complete functioning script at one point in time, these two variables were being set somewhere by the code. the current problem is that they are not. if i remember correctly, there's an installation folder/script for SMF. did you delete this after you installed it so that any random visitor wouldn't have the ability to mess up your installation? you can attempt to find out where these variables should have been set at in the code (i suspect in the Settings.php file) and try to correct the current problem, however it's likely this is just the tip of the iceberg and once you get past this group of errors, there are a bunch more. alternatively, why don't you just download and install the same version of the SMF forum software and start with a known working copy of the software? if you have a good backup of your existing database, you should be able to easily configure a new installation to access the previous data by performing the new install using a different database table prefix from your existing installation, then manually editing the settings to change the prefix to match your previous database tables. trying to make your site whole again, by finding and fixing the cause of each error will take you a while and may never be complete because you would need to test every possible feature to insure you found and fixed everything. staring with a new installation of the software and if necessary reusing existing data would be the surest way of getting the site back working. -
if you are dynamically building the query, you would just add one element to a $param array for each place holder. if you have a bunch of statically written queries, you would build the $param array to match the place holders in each query. i/we don't see what problem you are having applying this to your code since you haven't shown us any actual code/context. $key = "+some +keywords -here"; // a sample boolean mode query string that's been input to your code // the params array for a query that has 3 place holders - :key1, :key2, :key3 $params = array(':key1'=>$key, ':key2'=>$key, ':key3'=>$key); // note this is also of the format that you could use $stmt->execute($params) // bind the parameters foreach($params as $k=>$v){ $stmt->bindParam($k, $v); }
-
this may actually be a good place to use a ? place-holder rather than a named one so that you don't need to generate anything special in the sql query syntax. you would only need to know the range of integer numbered indexes they are in the bind statement.
-
from your previous thread -
-
Filling in input value based on selection
mac_gyver replied to winter-ale's topic in PHP Coding Help
your absence-get.php page doesn't show any code making a database connection and the items wezhind found would have been throwing php errors. for the time being, forget about using ajax, just have your html form submit to the absence-get.php page and get both parts working without any errors, retrieving and echoing the expected data. edit: the posted code, even after correcting the syntax errors that wezhind found, throws this fatal parse error - Parse error: syntax error, unexpected '$startshift' (T_VARIABLE) in your_path\absence-get.php on line 7 and doesn't even run. you are missing a ; on the preceding line. -
btw - i visited the link that hansford posted. if this code is from that purchased script, it's likely copyrighted by the author and no part of it can be posted by you. i have hidden those posts in this thread. now as to your change. if you are asking for the ability for someone to auction x of the same item, each one separately, its going to take changing more than a few lines of code to accomplish this as each one is actually a separate auction, with its own set of bids, its own winning bid, and winning bidder.
-
the reason you are not getting the help you are expecting, is because what you are asking for is not programming help, but a full course on programming and then for someone to figure out what the 1000+ lines of code you have posted do and at least for someone else to find and tell you where in them you need to make the changes to accomplish what you want. that's not what help forums are able to do for you. what we can do is, if you have narrowed down the problem to just a small section of code, made an honest attempt (not just randomly trying things) to make the change you want, tested and debugged the code you have changed, and cannot get it to work, then we can help you debug what's going on or what is needed. if you are not already a good php programmer, so that you can even understand the code you are looking at, tackling a project that has this much code is not going to go well and it's also not going to be the best way of learning programming. you need to have a background in the programming language first, accomplishing small code projects before you jump in trying to make or change something like a wordpress plugin.
-
there is no simple way of doing this using mysqli prepared queries. you will need to dynamically call the bind_param() function using the call_user_func_array() function or by using the reflection class (there are examples of both of these methods in the user contributed notes for the mysqli bind_param() function in the php.net documentation.) using PDO with prepared queries is actually easier. since each bind statement is called separately, you can just loop over the $param array and bind each value.
-
in the same php script that's throwing the error about the column name, what is the output from a SHOW CREATE TABLE users query? this type of error is typical of having multiple databases or tables and selecting the wrong database on the connection or using the wrong table name in the query, either due to different spelling of the database/table name (perhaps your table with the timestamp column is actually user, not users) or if you are on an operating system that is case-sensitive for file names, your correct database name or table name is capitalized differently, such as Users.
-
based on what you have posted, this really isn't a 'prepared query' problem, but a program logic and a design problem. in addition to what has already been posted, your level choice (all, Beginner, Intermediate, Expert, anything else in the future...) needs to use numerical values in the program logic and in the database table (1 = beginner, 2 = intermediate, 3 = expert) , rather than keywords. you would then be able to use a value comparison <= in the query (leaving the term out of the query for the ALL choice.) if at this time you don't want to change your database to store numerical level values, you would use an array in your php code that takes the submitted number from the select menu to give you the corresponding term using keywords to put into the query.
-
you need to start a new thread for your ssl certificate question as it has nothing to do with the title and topic of this thread.
-
did you review your first post in the thread. there is no attached code. however, programming help forums are not here to read through a bunch of code and tell you what portions you need or don't need. if your programming skills are not at the level where you can even make an attempt at doing what you want, you should not expect someone else to do it for you for free. programming help != free programming services. make an attempt a creating your page, test and debug it, then if you cannot get your code to work, post the relevant code, any symptoms or errors you are getting from that code, a sample of the input data you are supplying to that code, what incorrect result or output you got from that code and data, and if not apparent by reading the code, what result you expected from that code and data.
-
how many of the actual data values ('Beginner', 'Intermediate', 7, 3, ...) that you have shown are directly from external user supplied data? if the values being used and the different conditions ('<=' vs '=') in the query are all produced by your program logic, with none of the actual values coming directly from external user supplied data, there's no need to use a prepared query for them. perhaps if you show how you are coming up with the values in $pp, $ll, and $room_no now, someone can help.
-
if your mention of getting an ssl certificate has anything to do with the suggestion of using openssl_random_pseudo_bytes(), there is no need for an ssl certificate to do so. you only need an ssl certificate if you are going to have visitors connect to your site via an encrypted connection - https://your_domain.com