Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. You are on your way to PHP zen.
  2. It may be time to cut off the UK's interweb. That will learn em.
  3. gizmola

    PHP or JS

    This thread could very well end up in the phpfreaks Hall of Fame.
  4. It looks from a quick glance at the form that your post script would get the value form $_POST['RID']. $rid = (isset($_POST['RID']) ? (int)$_POST['RID'] : 0; Then you simply have to do an update query. You have done other queries, so I'm sure you can figure that code out. Just call mysql_query(). Updated do not return a result set, but you can check mysql_affected_rows if you want to verify that something actually got updated. UPDATE daterange SET status = 'B' WHERE RID = $rid
  5. city_id is part of the primary key of the table, so it can not be null.
  6. The above actually came from a DUMP and I don't recall adding it initially but that was a year or so ago. Possibly the default MySQL setting. I think you should add the level field to qualify the user logging in and directing them to the proper section. Maybe think of it as level1 has registered but not approved or has been banned, level2 is a user and level3 will be for you down the road when you work on that Admin section. Yes those are the character set defaults for your database.
  7. Don't worry about all that extra stuff he has. Your table is fine, and you can run that script in mysql. You of course need a database first, but I'm assuming you understand that and are using the database you want your tables to be in. So looking at this here are a couple of comments: username varchar(255) means you are going to allow usernames to be 255 characters. Seems far too large to me. Pick a reasonable username maximum size anywhere from 12-20 characters. password varchar(255) is not what you want. You are going to use a hash to store your passwords. Your main choices are md5 or sha1 Look at the manual page for each and decide which you want to use then have the password column be a char() of exactly the size you need. Make quick test scripts that call either or both of the functions if you want to understand how they work. You will need to add one more column.... `salt` varchar(16) default NULL
  8. run this in the sql window: describe model_in_city Paste the results in a reply.
  9. In php mail is just dumped off to the MTA. Read all the notes for mail until you fully understand it. What operating system are you developing under?
  10. Ok, so you want a login system -- how are you going to store the user data? Will you implement permissions aka ACL's? This is the first step.
  11. I pointed out the same thing that mjdamato did. Although you get an array with 2 keys in it... the keys are ordered smallest to largest. Notice you never get an array of: 9, 3 It will always be 3, 9. 5k words is large enough of an array that I would not want to be shuffling that every time, but that's just a guess. You would have to profile the different approaches: -shuffle() whole array -shuffle(array_keys()) -$max = count($lines)-1; $first = $lines[rand(0, $max)]; $lines[rand(0, $max)];
  12. The difference depends on the engine. A primary key in innodb actually dictates the physical ordering of the data on disk. The innodb data file is basically a giant index itself that is already ordered in PK order and it contains all the data, so whenever you need to get some rows out, if the primary key was used innodb already has the data available, rather than having to first read the index file and then read the actual data. A myisam PK is exactly the same as a table with a unique index on the same column(s).
  13. One other thing is that if these arrays are going to get large at some point, it would probably end up being much faster for you to just generate 2 random numbers inside your loop and use those as keys.
  14. The first thing is that if you shuffle() the original array there is no point in calling array_rand(). As mjdamato showed... one thing I noticed is that they changed the way the function works recently. The old array of keys used to be shuffled but now you get them in order. I don't know how many elements you have in your words.txt, but as it is now you will always get the keys in order. You could shuffle() the keys, but you might just as well shuffle the $lines array. At any rate: This code: for ($i=0; $i $lines = array('apple', 'pear', 'banana', 'kiwi', 'raspberry', 'pineapple'); $keys = array_rand($lines, 2); echo "Pass $i\n"; var_dump($keys); } Produces: [david@benji ~]$ php -f arrayrand.php Pass 0 array(2) { [0]=> int(1) [1]=> int(5) } Pass 1 array(2) { [0]=> int(1) [1]=> int(2) } Pass 2 array(2) { [0]=> int(0) [1]=> int(4) } Pass 3 array(2) { [0]=> int(0) [1]=> int(1) } Pass 4 array(2) { [0]=> int(2) [1]=> int(4) } Pass 5 array(2) { [0]=> int(2) [1]=> int(5) } Pass 6 array(2) { [0]=> int(0) [1]=> int(3) } Pass 7 array(2) { [0]=> int(0) [1]=> int(1) } Pass 8 array(2) { [0]=> int(0) [1]=> int(2) } Pass 9 array(2) { [0]=> int(0) [1]=> int(1) } See the problem?
  15. i think it should probably be a word... i think i've used it several times before. However its not possible to say jquery is awesomer than ajax is it? it is, because I said it in my post. my reason being its easier to use ajax functions via jquery, than writing them yourself, for me at least. jquery utilizes asynchronous functions...which is what I believe you are talking about...AJAX uses them as well Ajax is the buzzword for making asynch httpd connections. It actually came about as an acronym for Asynchronous Javascript And XML, but people are much more likely to use json these days rather than xml. You can code this yourself, but you have to have functions that support the different implementations provided by the browsers. The specific function calls are totally different for IE and firefox. jquery just hides all that.
  16. No the browsers have no intrinsic way of playing an m3u/mp3. The data is simply being handed off to a plugin.
  17. There various ways to get the text inside paragraphs into variables. Two that are often used are using the preg_match function, and another would be to use http://www.php.net/manual/en/domdocument.getelementsbytagname.php to load the html in a domdocument and access the paragraph nodes. In either case, once you have the text in a string, you can use strlen to get the length of the strings.
  18. It will not use an index because there is no index it can use to limit the results. You need an index on surf_date.
  19. This was your question. Where is the string that you are creating that has the items with commas after them? That is the one you use the trim on.
  20. Yes of course. Variables are variables and mysql_connect() simply requires variables to plug into it's parameters when it is called. It doesn't care one bit whether or not those variables are elements in an array.
  21. Why do you want to make an entirely different mysql user? Will this user be used to create a new database?
  22. Build you string with all commas at the end, then: $string = trim($string, ',');
  23. Yes but that's why you should use the firebug net panel. You will see a line when the ajax call goes, and you will see what the url is and what the response data is. If there is a problem with the get param, you will see it there. You can also try the good old alert in there for the xmlHttp.responeText.
  24. if ($ir['donatordays'] > 0) { $interest_rate = .06 } else { $interest_rate = .02 } $interest= $ir['bankmoney'] * $interest_rate; This willl not fix your problem because your existing code is already valid. Like I said, you should add: var_dump($ir); Before your block and run the script and take a look at what is in the $ir array, making sure that the values are what you expect them to be.
  25. What have you tried so far?
×
×
  • 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.