Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. There's a way to do this, but it's the opposite of how you're thinking about it. What you instead try and do is an INSERT and use the ON DUPLICATE KEY UPDATE clause. However that depends on having a key violation occur on the insert, which requires that this link column be unique or the primary key, which might not be the case. Truthfully, I think your best course in this case (as best I understand it with the minimal info you've provide) is to use the method you described, and get a list of link rows that actually exist, and build your updates off that, and then insert new rows that aren't in the list. Pseudocode: Start with list of links in an array. Use this array to build the IN of your query. Something like a: SELECT DISTINCT link FROM TABLE where Link IN ('link1', ....) would give you a list of links that actually exist. Then PHP's http://www.php.net/manual/en/function.array-diff.php would let you combine the original list and the "actually exists" list to get the "INSERT" list. Obviously your fist list that comes back from your query is the list of rows you UPDATE for.
  2. Collation and character set are 2 different things. Can you verify for the user table what the character set is. Please do this from mysql or phpmyadmin sql window: SHOW CREATE TABLE tablename; tablename should be your user table name, whatever that is. Then paste the contents in a reply.
  3. Browsers do not support writing data to the local machine, other than cookies. There are plugin specific ways around this, but in each case it requires that the user install a plugin. I don't know how serious you are about this, or what sort of impetus users would have to use your site, but the most viable way of doing this, and actually expecting it to work is to use flash, since flash can read/write files. You could of course also use a cookie, but people routinely delete their cookies, and once that happened, a person who was "registered" would not be able to ever login again, because the file they needed would be gone. I'm not sure why this is important to you, in fact it sounds like a bad idea to me, but without a better explanation of why this "feature" is desired, there's not much else that can be suggested.
  4. Well, this is for you to decide. However, it seems that your issue is not with the data but rather with your mismatched database character set to the one you are claiming to use when you render your pages. If the mysql charset is 8859-1 then you should emit that as the charset for your page, rather than claiming to use utf-8 which in fact you aren't using. Once you do that, the characters that are in there -- which are valid 8859-1 characters, will display fine, and you'll not have an issue. Otherwise, what you are doing is basically making sure that those users you are changing are not going to be logging in again, because you destroyed the username they had been using.
  5. No, what you want to do is add the 3 columns together, if I understand your issue. I'll phrase what I think you meant this way: "I have a table, that has 3 columns in it. Any of the 3 columns could have a value. I need to sum a bunch of rows, using whatever number(s) are available for any of the 3 columns." So the IF() just helps that you can add them all together, regardless if they have a value or not using something like SUM((IF(onecolumn > 0, onecolumn, 0) + IF(twocolumn > 0, twocolumn, 0) + ...) At this juncture we really need to see a describe or export for the table in question. Your names keep changing in your descriptions. If it's truly a datetime column, in order to group by date you need to either apply a > and
  6. You have a character encoding problem. Those are not space characters as can be seen from your own screenshot. Look at the 2nd place you display the name, and notice the FF/FD boxes. This leads to all sorts of questions like: what is the charset of the page that is rendered (UTF-8?) and does this match the character set used in the mysql table?
  7. Well, hopefully you get the idea, that you can use the IF() for each column to pass back a zero even if it's null. IF() basically is a mysql version of the php ternary operator.
  8. The reason saders code didn't work is because of the first VALUES for 'id' where he passed -- ''. This is an empty string, but the id column is an integer type. A string does not match an integer, so you got the error. When you pass the NULL keyword as phpMyAdmin did, then it works ok, but the truth is you can omit the id entirely from the insert statement both in the column list and the values. So this should work... (just small rwork of saders's code). $query = mysql_query("INSERT INTO bugs (reporter, title, desc) VALUES ('$username', '$title', '$desc')") or die('Could not insert data because '.mysql_error());
  9. Take a look at mysql IF() operator. Also please don't describe your posts as Urgent. It *almost* made me skip your thread. We spell out our distaste for that in the rules.
  10. Cookies are only read in the header of an HTTP response. So you can't set a cookie and expect in the same script to read it. If the browser went ahead and set the cookie, then in future requests it should be available.
  11. Ok, I see we were on the same page, your original description made it seem like you wanted the opposite. Glad you got it sorted out.
  12. I don't follow you. The goal of "search engine friendly" url rewriting is to take a parameterized real url like: http://mysite.com/index.php?page=home and allow someone to instead use http://mysite.com/home/. In that case the rewrite rule will parse the last part of the url and turn that into the parameter to page=.
  13. It's because you're trying to use the php block operator "{}" rather than the array operator "[]". Hence your array remains undefined. Try this as your array definition: $fields['Name'] = "Name"; $fields['Email'] = "Email"; $fields['Subject'] = "Subject"; $fields['order'] = "Order"; $fields['quantity'] = "Quantity"; $fields['Donation'] = "Donation";
  14. Well it looks like there is already data in the bak_banner table.
  15. Hello Joe, Please use [code=php:0]... [/code] Around your code snippets. It's easier to read that way. I editted your post to do this, which is something I won't do in the future, but seeing as this is your first post. I also took out your email addy's, don't think you want to include those, or specific urls or passwords in the future. This site is indexed heavily by google.
  16. Oh should i add i have been googling for hours and can only find login forms..... Except that this forum is for people trying to learn how to code php, or at very least customize something. There are plenty of script index sites like Hotscripts.
  17. Well it seems fairly obvious that you will want to try and call your HyperlinkText() function. How about: $post = HyperlinkText(stripslashes($post));
  18. Ditto what Mchl wrote. Also if you want to actually pass the password on the command line prompt you have to use --password. The -p will interactively prompt you for a password which is actually better, because if anyone on the server runs ps or top, they would see the password in the process list.
  19. // ------------------------------- // Display Result // ------------------------------- function display_result() { global $rss_feeds; // Number Of Items @page $num_result = count($rss_feeds); $num_item = ITEM_PER_PAGE; if ($num_result $num_item = $num_result; } // Display echo ''; for ($x = 0; $x echo ' ' . $rss_feeds[$x]['title'] . '. ' . $rss_feeds[$x]['summary'] . 'Read Full Article '; } echo ''; return; }
  20. Well, sorry I misread your code -- you are matched, but I'd still move to what I had, and lose the shuffle() regardless.
  21. It looks to me like you have a mismatch of assumptions about your array. When the array is constructed this is what it looks like: $rss_feeds[title] = array(); $rss_feeds[summary] = array(); $rss_feeds[clickurl] = array(); Then you start trying to go through the array as if the first element was numeric, which it isn't, it has the 3 keys in: 'title', 'summary', 'clickurl'. Probably what you want in get_results is to remove the 3 lines where you assign the title, summary and url to this: $rss_feeds[] = array('title' => $rss_title, 'summary' => $rss_summary, 'clickurl' => $rss_clickurl,); Shuffle is still going to make the order random, so you need to lose that.
  22. There are 2 issues I see. 1. You need to select a database with mysql_select_db. 2. You should not be passing 'null' which is string = "null" for the first parameter. I'm assuming that's an auto_increment integer key. If so, either pass null without the single quotes, or better yet, omit it entirely from the column list and values. I can't say for sure, but probably: if ($task == "insert"){ $query = "INSERT INTO `main`.`links` (`address`, `linkdisplay`) VALUES ('$_POST[address]', '$_POST[linkdisplay]')"; $result = mysql_query($query, $dbConn); if (!$result) { // Log out mysql_error(); } } // end if The main issue however, is that to catch errors you need to grab the result and if the result is false, check the mysql_error() function to determine what the problem is. Then you don't have to guess.
×
×
  • 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.