Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. From my signature -
  2. I don't see the need for the hidden field at all, just use the value as the country_id[...] index - <input style="width: 100%; height: 5%;" id="country_data" type="text" name="country_id[68]" /> <input style="width: 100%; height: 5%;" id="country_data" type="text" name="country_id[28]" /> ....
  3. Remove - http://us3.php.net/manual/en/function.str-replace.php Put back - http://us2.php.net/manual/en/function.number-format.php All the basic things that php (or mysql) can do, can be found by looking in the php/mysql documentation.
  4. Use - GROUP BY userid in your query. This will consolidate all the rows for each different userid into one row per userid. You will get the first row encountered for each userid.
  5. ^^^ Then you will need to increase the value of the 2nd parameter in the fgetcsv() statement.
  6. Your mysqli_query() statement is written wrong (the first parameter is expected to be a mysqli connection link, but you supplied it a null value) and your mysqli_error() statement is written wrong (you supplied it with no parameter but it expects a mysqli connection link.) If you want help with your code, you would need to post it.
  7. Define: "that has been encrypted and decrypted" The only way you are getting &#39 stored in the database is if the data already contained html entities before being stored into the database (and the solution would be to use html_entity_decode with ENT_QUOTES as the second parameter on the data before inserting it.)
  8. Usually include is used to do this so that any php code in the file will be parsed as php code.
  9. If you store the matching in/out DATETIME pairs together in one row (id, user_id, datetime_in, datetime_out) you can perform the calculation for the pair directly in the query when you select the data and you can even sum the totals for each user_id per time period directly in the query. See the mysql timediff function for example - http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_timediff
  10. The only way a count() of the $data array would give that high of a value is if there are no new-lines in the file or they are not being seen by php. Perhaps if you post an example of what the csv file structure looks like (how many values per line do you expect to get.)
  11. Had you set up (or choose to alter) your table so that it makes better use of the database engine, you can do what you are asking easily in the query and you could have saved typing all the repeated information for each column. The following alternate data method is tested - The table: CREATE TABLE `notices` ( `id` int(11) NOT NULL auto_increment, `notice` text, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 display code: <?php $html="<table>"; $q="select * from notices WHERE notice != '' order by id"; $r=mysql_query($q); while($o=mysql_fetch_object($r)){ $html.="<tr><td colspan='2' bgcolor='#896B45'><div style='padding:10px;'>&#38;#8226; {$o->notice}<br></div></td></tr>"; } $html.="</table>"; notices_admin.php code: <?php $max_fields = 50; // number of form fields to show $ff=$_POST; // multi value REPLACE query - REPLACE INTO notices (id,notice) VALUES (x,'notice'),(y,'notice'),(z,'notice'),... if (isset($ff['submit'])) { //post data looks like: $ff['notice'][1..50] The keys (1-50) are the table id's. $query = ''; foreach($ff['notice'] as $key => $value){ $query .= "($key,'$value'),"; } $query = "REPLACE INTO notices (id,notice) VALUES " . rtrim($query,','); mysql_query($query); } ?> <html> <head> </head> <body> <form name="noticesform" method="post" action="notices_admin.php" enctype="multipart/form-data"> <?php $page_content = db_select("select * from notices order by id"); // get existing data (after it has been updated(repalced) above $i = 1; // index counter $content = ''; foreach($page_content as $pc){ $content .= "Notice: $i <textarea name='notice[$i]' cols='110' rows='3' class='input'>{$pc["notice"]}</textarea><br />\n"; $i++; } // produce remainder of fields (when less than the max exist in the table) for($j = $i; $j <= $max_fields; $j++){ $content .= "Notice: $j <textarea name='notice[$j]' cols='110' rows='3' class='input'></textarea><br />\n"; } echo $content; ?> <input type="submit" name="submit" value="Click here to update" class="input"> </form> </body> </html> echo $html; ?>
  12. There's nothing weird about declaring a variable before you reference it.
  13. if (isset($_SESSION['username'])) {
  14. Most form fields will be set, even if they are empty. You should probably be using empty or != '' (not equal to an empty string), depending in what sort of values you are expecting (a zero is considered to be an empty value by the empty() function.)
  15. You need to use isset to test a variable that might not exist.
  16. You can echo mysql_error(); to find out why the query is failing.
  17. Count($data) will give the number of elements in data and the highest index would be one less than that number.
  18. Your code works for me (inserts the $session_data into the table), provided you actually set a session variable. BTW: You are going to want to use a REPLACE query instead of an INSERT query.
  19. All you need to do is set the session.save_path to be to a 'private' folder within your account's folder tree.
  20. This is code you are using in your existing problem/thread. It is not a new topic just because you are getting a syntax error with it. Stick to a single thread for the same problem.
  21. That's because the code you put in does not have or set any value for that field in the database. Someone has suggested twice in this thread that you need to define how you are going to store multiple images and associate them with the correct information in the database. The sample code I posted did associate the multiple files with the id in the database by including the id as part of the file name. If you want something different than that method, you will need to define it and then write the code to accomplish it.
  22. And in your // failure logic you can test the value that mysql_errno returns to see if the query failed due to a duplicate key (the value returned should be 1062, but you should test this to make sure) and setup your message and logic needed to prompt the user for a different username.
  23. What does a phpinfo(); statement show for the actual session.save_path and session.gc_maxlifetime settings? Is the session.save_path the common /tmp folder that all the accounts running on the server use or it is set to a 'private' folder within your account's folder tree?
  24. Binary data would be something that you would inserted into a blob data type - http://dev.mysql.com/doc/refman/5.0/en/blob.html Most people attempt to insert files, but it can be any data you want to be treated literally without any character encoding/decoding by the database.
  25. Both code examples you posted are invalid php. It would take seeing the actual code that does not work in order to be able to tell you why it does not work. xxxxx out any sensitive information you don't want to post, but don't change any of the actual syntax of the code.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.