-
Posts
5,449 -
Joined
-
Days Won
174
Everything posted by mac_gyver
-
@selliottsxm, slow down. you actually need to read the documentation at php.net for the functions you are trying to use so that you know what they do and how they are used. there are also pretty good beginning code examples in the php.net documentation. also, it's against the forum rules to pm members directly asking for help.
-
PHP Not displaying properly
mac_gyver replied to MrTreefo's topic in PHP Installation and Configuration
if you do a 'view source' of that page in you browser, do you see the complete original raw php code? if so, either your live web server doesn't have php installed or the file extension of that page (it should be .php, using anything else requires that your web server be configured to treat it as php code) isn't configured to be parsed as php code or php isn't enabled in the folder where you put your files. -
the php datetime functions has a DatePeriod class that allows iteration over a set of dates - $start = '2014-05-01'; $end = '2014-07-01'; $start_date = new DateTime($start); $end_date = new DateTime($end); $end_date = $end_date->modify('+1 day'); // if you need the end date in the range (DatePeriod is not inclusive of the end date) $interval = new DateInterval("P14D"); // 14 days $dates = new DatePeriod($start_date, $interval, $end_date); // Traversable date range foreach($dates as $date){ echo $date->format('Y-m-d') . '</br>'; }
-
no. if this is something to do with the safe mode or open_basedir, the fopen() statement you are currently using won't be able to access the file in the temp upload directory. the move_uploaded_file() statement however can read the file in the temp uploaded directly and would be able to move it to a location within your account's directory tree, where php would have the ability to access it using fopen() -
-
Pagination question for limiting search results
mac_gyver replied to mike2's topic in PHP Coding Help
programming is not for the timid. you have to be willing to try things (on a development system) and in fact since programming gives you immediate feedback as soon as you run your code, it's easy to see if something you wrote or changed produced the intended result. that you are asking if you cannot just incorporate the pagination code somewhere in your main code (you can, but you have to figure out which parts of it would be used at all, where each of the remaining functional parts of it would go, and what changes you would need to make to your main code to retrieve the correct rows based on which page of results has been requested) or are asking where in your code something that someone suggested should be put, says you are not at the point of understanding enough about what the code you have is doing to be able to write or change things in it (the posted pagination code itself contains several mismatched variables that would prevent it from working as is), so it's going to be a little hard for you to complete the current task unless you manage to acquire some skills to read and understand what the code is doing and to combine it in a way the produces the functionality that you need. -
bumping this topic for the op.
-
use var_dump() on your two arrays being compared, that would help show things like white-space in with the data.
-
output buffering should only be used when you want to buffer output, not to try to prevent errors when your code runs. the way to fix an error is to correct the underlying problem that is causing it.
-
you have a reply in one of your previous threads that mentions why this error is occurring and how to rearrange the code on your page to fix it - http://forums.phpfreaks.com/topic/288720-student-login-issue/?do=findComment&comment=1480736
-
all the columns you have selected are actually in the result set sent to php. this feature is the result of using an associative fetch function where a later column with the same name as an earlier column overwrites the previous column's data when the associative array is built. that's because query browsers fetch the data as a numerical array and use the column metadata from the result set to get the corresponding table/column display names. afaik - there's no built in query syntax that does this. you would either need to manually write out the query with alias names or dynamically produce the query statement using php, defining lists of what you want to select from each table and let your php code produce the select term with appropriate table_column alias names. you could also take the query browser approach and do this using php code after the fact, to produce your own table_column array indexes from the field metadata. in looking at what the mysqli->fetch_fields() method returns, for each field you get the [name] selected column name/alias, [orgname] original/actual column name, [table] table name/alias, [orgtable] original/actual table name.
-
you are likely getting a fatal parse or runtime error in the code in your included file. you NEED to have php's error_reporting set to E_ALL and display_errors set to ON in your php.ini on your development system so that php will HELP you by reporting and displaying the errors it detects.
-
what do you see in your browser when you do a 'view source' of the resulting page? if you see the actual contents of the navbar.php file, i.e. the php function definition, the problem is the use of short opening <? tags. you should always use full opening <?php tags.
-
making a list in a column will require a lot of extra code and queries in order to store values (you must insure they don't already exist in the list), find values, and delete values. the correct method is to have a table that contains one row for each data value. the table would have columns for an id, a 'parent' id (what is being liked), and a 'child' id (who liked it.) the combination of the parent and child id columns would be defined as a unique key. this will enforce uniqueness in the values. to insert a value, you can just insert the new row. if the insert fails with a duplicate key error, you will know that the combination already existed. to find any or all likes by any one or every one, you just query for the child id you want or order by the child id to get all rows by each id together (you would group by the parent or child ids if interested only in a count of likes for an item or a count how many likes someone has given.) to delete any row or rows, you can reference them either by their id, or by the parent id, or the child id values. also, to get the list of actual information, you would use a JOINed query between the above described table and the tables holding the information about the parent and child id's (even if those happen to be the same table, such as a user information table.)
-
you can use an UPDATE query with the CONCAT() function to do that. i hope you are not planning on using this to build a delimited list in a column in a database table?
-
lol, the php documentation for uniqid recommends using openssl_random_pseudo_bytes - http://us1.php.net/manual/en/function.openssl-random-pseudo-bytes.php
-
your database table(s) should continue to use the auto-increment id as a primary key. this id should be used for internal purposes, i.e. relating database tables to each other, identifying the user in a login session variable... if you need to have a random and unique id for external use, i.e. a remember-me cookie, a password reset token, a form/link consumable token,..., then generate a value using uniqid(), and store this for each visitor in addition to the auto-increment id. you can enforce unique values using the database table, by defining any database column storing the values as a unique key and checking if when storing the value if the query produced an error for a duplicate value.
-
clearing cache or something for all users
mac_gyver replied to ryanmetzler3's topic in PHP Coding Help
that fact that there's a pollid that the cookie is keyed to, implies that the question, answers, and poll results also use the pollid. you would create a new/different poll by inserting the new question/answers using a different pollid, that would then also store the results and make a different cookie name for that new pollid. i'm betting the script has a 'create/insert' new poll interface that would do this for you. -
simple Problem: PHP form ints not declared
mac_gyver replied to Chezshire's topic in PHP Coding Help
form data will only exist after the form has been submitted. all your form processing code needs to be inside a conditional statement that tests if the expected form has been submitted so that the data values it (the form processing code) references will exist. -
clearing cache or something for all users
mac_gyver replied to ryanmetzler3's topic in PHP Coding Help
your two threads have been merged together. don't start multiple threads for the same problem. -
Recoding old website code to today's standard.
mac_gyver replied to portoholic's topic in PHP Coding Help
there's also a section in the documentation that addresses the mysql/mysqli/pdo database libraries - http://us2.php.net/manual/en/mysqlinfo.api.choosing.php -
Recoding old website code to today's standard.
mac_gyver replied to portoholic's topic in PHP Coding Help
the php.net documentation appendices contain migration sections that list what has been changed, removed, or added to php over time. becoming familiar with that information would be your first step - http://us3.php.net/manual/en/appendices.php as to the apostrophe's in data being put into database query statements, the specific reason your code stopped working was due the disabling and eventual removal of php's magic_quotes, which were escaping ALL external data, without taking into account things like character sets or even if you wanted that data to be escaped. however, instead of using addslashes(), which is identical to what the magic_quotes did, you should use your database library's proper string escape function (or use prepared queries with bound values.) -
in case the OP revisits this thread, you cannot use a header() statement, or a session_start() or session_regenerate_id(); statement after you have output anything to the browser. the solution to this it to organize the php code on your page so that the 'business logic' (determines what to do on the page and gets the data the page needs) comes first and the the 'presentation logic' (deals only with the production of the html/css/javascript output) comes last. you also need to set php's error_reporting to E_ALL and display_errors to ON in your php.ini on your development system so that php will help you by reporting and displaying all the errors it detects. your header() statement would be producing php errors since it comes after you have output a bunch of html on the page.
-
it's likely that the ? character that you are entering isn't an ascii ? character and results in the whole ... .php?.... string looking like a domain name and your browser is going off and trying to run a search for it instead of browsing to your page on your development system.
-
Pagination question for limiting search results
mac_gyver replied to mike2's topic in PHP Coding Help
yes, it would be wrong. there's a forum rule - basically, programming help forums are for programmers or those learning programming to get help (publicly, in the forum, so that problems and solutions would be of help to others) when they get stuck, after they have made an attempt at solving their programming problem. programming help forums are not script repositories, nor are we here to find or give you code that does what you want. since you have no php/coding experience, the only progress being made is by others writing up code for you, in the location where it's needed. that's not what help means. i recommend that you post in the Job Offerings forum section. you would want to list all the features at once since the overall design needs to take into account everything to avoid backtracking/rewriting that occurs when doing programming in a piecemeal fashion. btw - there's three different ways of replying to a thread that doesn't involve hitting the quote button. quoting everything just makes for a long thread to read or scroll over to find the actual information being posted. -
Pagination question for limiting search results
mac_gyver replied to mike2's topic in PHP Coding Help
i would also add that i suggested two different methods, you would need to pick one. you would use the first method if the underlying data is dynamic and could change during the visit to your site by any person, so that the changes would show up in the data. this method uses more resources since the swish query will be executed on every page load, not just when the search term gets changed. the second method would use less server resources, but the data would be static for the duration of one search/the visit to your site since the data from one single swish query/search would be stored in a session variable.