Re: [PHP] MD5 bot Question
hmm, why don't you md5 more then once.. for example, use a condition that will change with every visitor. like the third num in $_SERVER['REMOTE_ADDR']; or something of the sort. then make a loop.. say the third num in my ip address is 5 the person that visits after me would get my value, and say you were right before me and yours was a 7 the md5 check for me would look like md5(md5(md5(md5(md5(md5(md5($value))); and for the person right after me md5(md5(md5(md5(md5($value); this way for each visitor, a piece of the puzzle is changed. just an idea, and have no idea if it would even work for what your doing... Tijnema ! wrote: On 4/8/07, Tijnema ! [EMAIL PROTECTED] wrote: On 4/8/07, tedd [EMAIL PROTECTED] wrote: Well, I cracked it for you :) http://86.86.80.41/dev/debug/tedd.php At the bottom it shows you the MD5 code of your arrow image, and it shows you which way it points to :) If you're interested in the code: http://86.86.80.41/dev/debug/tedd.txt Tijnema Tijnema: Okay, I think I figured out a fix -- try it again. :-) http://sperling.com/a/arrows/ A little knowledge is a dangerous thing. Cheers, tedd Looks interesting. It generates a different MD5 each time I'll take a deeper look at it today, and hope to find a way to crack it :) Tijnema You can't stop me :) http://86.86.80.41/dev/debug/tedd.php It's cracked again :) and of course i show you the code: http://86.86.80.41/dev/debug/tedd.txt Waiting for your next try :P Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MD5 bot Question
indeed. i was just throwing out the idea of ever changing values. Robert Cummings wrote: On Sun, 2007-04-08 at 04:38 -0700, benifactor wrote: hmm, why don't you md5 more then once.. for example, use a condition that will change with every visitor. like the third num in $_SERVER['REMOTE_ADDR']; or something of the sort. then make a loop.. say the third num in my ip address is 5 the person that visits after me would get my value, and say you were right before me and yours was a 7 the md5 check for me would look like md5(md5(md5(md5(md5(md5(md5($value))); and for the person right after me md5(md5(md5(md5(md5($value); this way for each visitor, a piece of the puzzle is changed. just an idea, and have no idea if it would even work for what your doing... Ugh, don't do that... it's no more differentiated than doing the following which is cleaner: md5( $_SERVER['REMOTE_ADDR'].$value ); The above uses the IP address as a salt. But better yet, since the above is still prone to abuse by the same server making repeat attempts, create a multi-salt system... $salt1 = 'YoUR SeKreT SaLT'; $salt2 = time(); $salt3 = uniqid(); $md5 = md5( $salt1.'__'.$salt2.'__'.$salt3.'__'.$value ); Then in your form you include the value of $salt2, $salt3, and $md5. In this way only those who know the secret salt can rebuilt the md5 to check validity. Presumably you won't allow the same md5 to be used twice. The time is tracked so that you can limit validity of the salt for a period of time. So if the time on your server is more than 20 minutes ahead of the time for the submission, you can feel free delete entries ion your database since the time has expired. This allows you to not need to track all md5s ever generated. Only the last X minutes of md5s. If you implement this, Tijnema won't be able to break it. Cheers, Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MD5 bot Question
but most people have different ones :) you could also use a random position :) fooeee. Robert Cummings wrote: On Sun, 2007-04-08 at 05:41 -0700, benifactor wrote: indeed. i was just throwing out the idea of ever changing values. Except IP addresses aren't ever changing ;) Cheers, Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: What sripts,helpers to use for AJAX
im using http://www.prototypejs.org/ and have had no problems thus far. - Original Message - From: Mikey [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Thursday, March 08, 2007 10:02 AM Subject: [PHP] Re: What sripts,helpers to use for AJAX Otto Wyss wrote: I want to add some AJAX communication to my pages and would like to know, what scripts, helpers you would recommend. I don't want to use a full featured framework, just something to do the AJAX work. So far I've come across the following solutions http://prajax.sourceforge.net/ http://sanjer.berlios.de/ yet they both doesn't seem very much used. Does anybody know these or knows better alternatives? O. Wyss Scriptaculous - you get a whole heap of other stuff for free too. http://script.aculo.us/ Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] audio CAPTCHA - was Combining sound files
tried, and failed. got this error: Notice: Undefined variable: captcha in /home/httpd/vhosts/sperling.com/httpdocs/a/c/index.php on line 29 and no captcha was displayed. - Original Message - From: tedd [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Monday, February 26, 2007 8:04 AM Subject: [PHP] audio CAPTCHA - was Combining sound files Hi gang: Thanks for all the advice regarding combining sound files. I shall look into all of it. In the meantime, I am trying a different solution and would appreciate your review of the technique: http://www.sperling.com/a/c/ The point of this experiment is to speak the numbers required for a CAPTCHA protection scheme. I've had a few blind users report that this works for them, but considering all the different platforms and talents on this list, I thought that I would ask Does this work (i.e., speak the numbers) for you? The numbers to be spoken are printed on the top of this page for your notice. If you would be so kind, please review, provide me your platform type and success. Thanks. tedd PS: What does this have to do with php? Well... a good deal of the code is php and a mix of a bunch of other stuff (we don't live in a vacuum) -- so please permit me this indulgence. -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] audio CAPTCHA - was Combining sound files
yea, same for me... but maybe the variable needs to be defined for anything to happen, as we are probably supposed to press that before we speak tha captcha.. - Original Message - From: Németh Zoltán [EMAIL PROTECTED] To: benifactor [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Monday, February 26, 2007 8:18 AM Subject: Re: [PHP] audio CAPTCHA - was Combining sound files I got the same notice on the top of the page. besides that, when clicking the speak captcha button nothing happens greets Zoltán Németh 2007. 02. 26, hétfő keltezéssel 08.12-kor benifactor ezt írta: tried, and failed. got this error: Notice: Undefined variable: captcha in /home/httpd/vhosts/sperling.com/httpdocs/a/c/index.php on line 29 and no captcha was displayed. - Original Message - From: tedd [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Monday, February 26, 2007 8:04 AM Subject: [PHP] audio CAPTCHA - was Combining sound files Hi gang: Thanks for all the advice regarding combining sound files. I shall look into all of it. In the meantime, I am trying a different solution and would appreciate your review of the technique: http://www.sperling.com/a/c/ The point of this experiment is to speak the numbers required for a CAPTCHA protection scheme. I've had a few blind users report that this works for them, but considering all the different platforms and talents on this list, I thought that I would ask Does this work (i.e., speak the numbers) for you? The numbers to be spoken are printed on the top of this page for your notice. If you would be so kind, please review, provide me your platform type and success. Thanks. tedd PS: What does this have to do with php? Well... a good deal of the code is php and a mix of a bunch of other stuff (we don't live in a vacuum) -- so please permit me this indulgence. -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] audio CAPTCHA - was Combining sound files
i was just trying again, and entered 406 via keyboard and pressed submit, and it said i was successful, then i pressed back on my browser and no longer had the error. it displayed the captcha at the top of the page where the error was. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] input on sessions vs cookies
i would like your input on session vs cookies regarding login data like usernames/passwords ect...
Re: [PHP] input on sessions vs cookies
as of right now, when the user logs in, i have a cookie storing username... then on all of the pages i need data i have it query the database and using the cookie data to retrieve user information.. is there a more secure way to do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to call image from mySql to php file
$query = mysql_query(SELECT logos FROM table WHERE sno = '$sno' limit 1) or die(mysql_error()); while ($result = mysql_fetch_array($query)) { $sno = $result[logos]; } ? img src=?php echo($sno); ?/img hope it helps - Original Message - From: Fahad Pervaiz [EMAIL PROTECTED] To: [EMAIL PROTECTED]; php-general@lists.php.net Sent: Friday, February 23, 2007 9:38 PM Subject: [PHP] Re: How to call image from mySql to php file #ORIGINAL# I have a field in database called logos which has one value images/logos/some_logo.jpg In my php I am trying to call it in my php file as image. With this code. $sno = $_REQUEST['sno']; $query=SELECT logos FROM table WHERE sno = '$sno'; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $logos=mysql_result($result,$i,logos); echo div p $logos /p /div; ?/div But getting errors. What is the way to call image in php file from the database. I know that this is a very basic question but first time for me. I ignored this in the begining but now its right infront of me. Please advice. #END ORIGINAL# There are two ways to store images in databases. First is that you upload your images to a directory and store path to that image in the database. In this case make sure that your field size is large enough to store the complete path. You can use the following code to retreive the image and display it. $sno = $_REQUEST['sno']; $query=SELECT logos FROM table WHERE sno = '$sno' limit 1; $result=mysql_query($query); $num=mysql_numrows($result); if ( ! $result ) die(Unable to get records); while($row= mysql_fetch_array( $result )) { $image= $row[sno]; } mysql_close(); echo div img src='$logos' border='0' /div; The second method is a bit complicated. You store images in a binary field of database and when you retrieve the image, you retrieve it via proxy file e.g. image.php the image.php outputs the image using header ? header('Content-type: image/jpeg'); $sno = $_REQUEST['sno']; $query=SELECT logos FROM table WHERE sno = '$sno' limit 1; $result=mysql_query($query); $num=mysql_numrows($result); if ( ! $result ) die(Unable to get records); while($row= mysql_fetch_array( $result )) { $image= $row[sno]; } mysql_close(); echo $logos; ? you can make call to it from you abc.html as follows div img src=image.php?sno=?=$_REQUEST['sno']? / /div -- Regards Fahad Pervaiz www.ecommerce-xperts.com (Shopping Carts, Framwork for Multilingual Web Sites, Web Designs) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] who is online?
i have built a function to tell me how many users are on my site at any given time... ? //define function function bc_who ($who, $location) { //first we erase any expired entries //entries will expire after 5 mins $whoTime = time(); $whoTime = $whoTime - 300; mysql_query(Delete FROM bc_who where expire $whoTime) or die(mysql_error()); //here we difine the variables needed to preform the check $whoExpire = time(); $whoIp = $_SERVER[REMOTE_ADDR]; //this will be changed as soon as user registration is finished $whoUser= Guest; //do the actual mysql queries mysql_query(Delete FROM bc_who where '$whoIp' = ip); mysql_query(Insert INTO bc_who (id, user, ip, location, expire, status) VALUES (NULL, '$whoUser', '$whoIp', '$location', '$whoExpire', '$whoStatus')); } //end who is function ? this fuction works fine, however, i want to know if what i am about to ask is possible. the problem i have is, this function assumes that after five minutes if the user has not refreshed the page, or gone onto another page the user must be gone. in reality, i have pages users might be on for an hour or so without refreshing. i want my whos online to as acurate as possible so is there a way to do this on the fly? like, forgetting about the expire time and using a server side peice of code to communicate to the database, when there is no more communication the entry is deleted? please tell me there is a way, thank you in advance.
Re: [PHP] who is online?
sorry if you misunderstood, i just wanted to know if it could be done with php alone. - Original Message - From: Stut [EMAIL PROTECTED] To: benifactor [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Monday, February 05, 2007 5:18 AM Subject: Re: [PHP] who is online? benifactor wrote: i have built a function to tell me how many users are on my site at any given time... ? //define function function bc_who ($who, $location) { //first we erase any expired entries //entries will expire after 5 mins $whoTime = time(); $whoTime = $whoTime - 300; mysql_query(Delete FROM bc_who where expire $whoTime) or die(mysql_error()); //here we difine the variables needed to preform the check $whoExpire = time(); $whoIp = $_SERVER[REMOTE_ADDR]; //this will be changed as soon as user registration is finished $whoUser= Guest; //do the actual mysql queries mysql_query(Delete FROM bc_who where '$whoIp' = ip); mysql_query(Insert INTO bc_who (id, user, ip, location, expire, status) VALUES (NULL, '$whoUser', '$whoIp', '$location', '$whoExpire', '$whoStatus')); } //end who is function ? this fuction works fine, however, i want to know if what i am about to ask is possible. the problem i have is, this function assumes that after five minutes if the user has not refreshed the page, or gone onto another page the user must be gone. in reality, i have pages users might be on for an hour or so without refreshing. i want my whos online to as acurate as possible so is there a way to do this on the fly? like, forgetting about the expire time and using a server side peice of code to communicate to the database, when there is no more communication the entry is deleted? please tell me there is a way, thank you in advance. Assuming you actually mean client side not server side (because server-side is what you already have), you could do this in a number of ways with Javascript. You could periodically call the server using XmlHttpRequest, or you could keep it simple and reload an image which points at a PHP script. Either way this is not a question for a PHP list because it relates to client-side code. Google will almost certainly have several useful sites. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] who is online?
hmm it was obvious to me, tis why i asked. just had to be sure. thank you for your help. - Original Message - From: Stut [EMAIL PROTECTED] To: benifactor [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Monday, February 05, 2007 5:30 AM Subject: Re: [PHP] who is online? benifactor wrote: sorry if you misunderstood, i just wanted to know if it could be done with php alone. It can't, and this should be fairly obvious. If the client-side makes no contact with the server for a period of time, how do you expect it to know that the user hasn't moved to another page? The bottom line is that this needs some client-side code to work, whether it be Javascript or just an iframe with a meta refresh tag. -Stut - Original Message - From: Stut [EMAIL PROTECTED] To: benifactor [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Monday, February 05, 2007 5:18 AM Subject: Re: [PHP] who is online? benifactor wrote: i have built a function to tell me how many users are on my site at any given time... ? //define function function bc_who ($who, $location) { //first we erase any expired entries //entries will expire after 5 mins $whoTime = time(); $whoTime = $whoTime - 300; mysql_query(Delete FROM bc_who where expire $whoTime) or die(mysql_error()); //here we difine the variables needed to preform the check $whoExpire = time(); $whoIp = $_SERVER[REMOTE_ADDR]; //this will be changed as soon as user registration is finished $whoUser= Guest; //do the actual mysql queries mysql_query(Delete FROM bc_who where '$whoIp' = ip); mysql_query(Insert INTO bc_who (id, user, ip, location, expire, status) VALUES (NULL, '$whoUser', '$whoIp', '$location', '$whoExpire', '$whoStatus')); } //end who is function ? this fuction works fine, however, i want to know if what i am about to ask is possible. the problem i have is, this function assumes that after five minutes if the user has not refreshed the page, or gone onto another page the user must be gone. in reality, i have pages users might be on for an hour or so without refreshing. i want my whos online to as acurate as possible so is there a way to do this on the fly? like, forgetting about the expire time and using a server side peice of code to communicate to the database, when there is no more communication the entry is deleted? please tell me there is a way, thank you in advance. Assuming you actually mean client side not server side (because server-side is what you already have), you could do this in a number of ways with Javascript. You could periodically call the server using XmlHttpRequest, or you could keep it simple and reload an image which points at a PHP script. Either way this is not a question for a PHP list because it relates to client-side code. Google will almost certainly have several useful sites. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] who is online?
I agree. hey. for my $0.02 worth.. these kinds of questions are not exactly only php. however, i still see them as being valuable, and belonging to the php list, as they get into areas the php developers of sites might grapple with. i'm of the opinion more, rather than less. so if you have more intelligent discussions regarding php/site development technologies that integrate with php, this is the place for it!! peace.. -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Monday, February 05, 2007 5:31 AM To: benifactor Cc: php-general@lists.php.net Subject: Re: [PHP] who is online? benifactor wrote: sorry if you misunderstood, i just wanted to know if it could be done with php alone. It can't, and this should be fairly obvious. If the client-side makes no contact with the server for a period of time, how do you expect it to know that the user hasn't moved to another page? The bottom line is that this needs some client-side code to work, whether it be Javascript or just an iframe with a meta refresh tag. -Stut - Original Message - From: Stut [EMAIL PROTECTED] To: benifactor [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Monday, February 05, 2007 5:18 AM Subject: Re: [PHP] who is online? benifactor wrote: i have built a function to tell me how many users are on my site at any given time... ? //define function function bc_who ($who, $location) { //first we erase any expired entries //entries will expire after 5 mins $whoTime = time(); $whoTime = $whoTime - 300; mysql_query(Delete FROM bc_who where expire $whoTime) or die(mysql_error()); //here we difine the variables needed to preform the check $whoExpire = time(); $whoIp = $_SERVER[REMOTE_ADDR]; //this will be changed as soon as user registration is finished $whoUser= Guest; //do the actual mysql queries mysql_query(Delete FROM bc_who where '$whoIp' = ip); mysql_query(Insert INTO bc_who (id, user, ip, location, expire, status) VALUES (NULL, '$whoUser', '$whoIp', '$location', '$whoExpire', '$whoStatus')); } //end who is function ? this fuction works fine, however, i want to know if what i am about to ask is possible. the problem i have is, this function assumes that after five minutes if the user has not refreshed the page, or gone onto another page the user must be gone. in reality, i have pages users might be on for an hour or so without refreshing. i want my whos online to as acurate as possible so is there a way to do this on the fly? like, forgetting about the expire time and using a server side peice of code to communicate to the database, when there is no more communication the entry is deleted? please tell me there is a way, thank you in advance. Assuming you actually mean client side not server side (because server-side is what you already have), you could do this in a number of ways with Javascript. You could periodically call the server using XmlHttpRequest, or you could keep it simple and reload an image which points at a PHP script. Either way this is not a question for a PHP list because it relates to client-side code. Google will almost certainly have several useful sites. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Staff log-in
i actually just started my own non profit org... so now you can all give me things for free. :) p.s. i also accept donations via paypal :) - Original Message - From: Jochem Maas [EMAIL PROTECTED] To: tedd [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Friday, November 10, 2006 7:46 AM Subject: Re: [PHP] Staff log-in tedd wrote: At 7:16 PM + 11/9/06, Brynjar Guðnason wrote: Hi, I need a little php script. Staff log in by entering username and password and then the next time they enter their username and password they log out. The script has to take down the time they log in and log out. Then I should be able to read old log-ins and log-outs. I unfortunately can't make it myself because I don't have the knowledge, can anyone of you do this for me? It's for a small non-profit orginisation. Thanks in advance, Brynjar Gudnason. Brynjar: You say a little php script -- if you have no knowledge of how to do this, then what makes you think it's little? Stop and think dude -- you're asking for code that will keep track of users, passwords, deal with what happens if they lose their password, keeping passwords secure, keeping track of times on/off, and writing an admin to review/edit times and edit users (add, delete, ban) --this is not a little script. Lastly, I think we all know that non-profit simply means that at the end of the year you get to roll your profits over to the next year without incurring taxes on the excess. Nothing more. Plus, there's no limit or requirements as to the amount/percentage you pay yourself as compared to what amounts you apply to your cause. So, mentioning non-profit to me is like saying you're just another scam -- and one, who's trolling for free php services. it's a pity you pointed that out Tedd, I was about to post something along the lines of... I am non-profit person looking for a 'little girl' aged 18+ I guess it's no longer worth the effort given that you let the cat out of the bag! ;-) bootnote: mercy **ck - either a reference to my perverted comment above OR a 'little php script' written free of charge for a NPO; depending on what you think the **'s are hiding tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Staff log-in
give us (the list) the website address. - Original Message - From: Brynjar Guðnason [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Thursday, November 09, 2006 11:16 AM Subject: [PHP] Staff log-in Hi, I need a little php script. Staff log in by entering username and password and then the next time they enter their username and password they log out. The script has to take down the time they log in and log out. Then I should be able to read old log-ins and log-outs. I unfortunately can't make it myself because I don't have the knowledge, can anyone of you do this for me? It's for a small non-profit orginisation. Thanks in advance, Brynjar Gudnason. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pass value to next page
you could also do this all on one page... with different if statments to direct which part of the process your actually in. if (processone) { blah... blah... } if (processtwo) { blah... blah... } this is how all of my pages work, to an extent, and it make things much easier not having to pass variables from page to page. hope it helps. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO $variable
thank you for schooling me :) i learn something new everyday! - Original Message - From: Richard Lynch [EMAIL PROTECTED] To: benifactor [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Monday, October 09, 2006 11:02 AM Subject: Re: [PHP] ECHO $variable On Mon, October 9, 2006 7:45 am, benifactor wrote: the way i posted worked fine with out either... he doesn't need to use these to format the way his output is displayed, he only needs to use the proper php syntax if i am correct. You were wrong, and you're still wrong. :-) Try it and see. http://php.net/htmlentities is the correct solution. htmlspecialchars only catches a tiny subset of what *might* be in the string... So it will work if you can guarantee that only those limited set of chars will ever be in there. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO $variable
you should try this... $saved_message_title = '1 Peter 5:7 Cast all your cares on Him for He cares about you'; - Original Message - From: Ron Piggott (PHP) [EMAIL PROTECTED] To: PHP General php-general@lists.php.net Sent: Saturday, October 07, 2006 11:39 PM Subject: [PHP] ECHO $variable In one of my scripts I have input type=text name=message_title size=40 maxlength=80 value=?echo $saved_message_title;? where $saved_message_title is 1 Peter 5:7 Cast all your cares on Him for He cares about you --- note the When this is displayed on the screen $saved_message_title reads 1 Peter 5:7 I am assuming the closes the value= How may I echo this to the screen and have the full text be displayed, not just 1 Peter 5:7 ? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ECHO $variable
the way i posted worked fine with out either... he doesn't need to use these to format the way his output is displayed, he only needs to use the proper php syntax if i am correct. - Original Message - From: Penthexquadium [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Sunday, October 08, 2006 1:41 AM Subject: Re: [PHP] ECHO $variable On Mon, 9 Oct 2006 00:23:00 -0700, benifactor [EMAIL PROTECTED] wrote: you should try this... $saved_message_title = '1 Peter 5:7 Cast all your cares on Him for He cares about you'; - Original Message - From: Ron Piggott (PHP) [EMAIL PROTECTED] To: PHP General php-general@lists.php.net Sent: Saturday, October 07, 2006 11:39 PM Subject: [PHP] ECHO $variable In one of my scripts I have input type=text name=message_title size=40 maxlength=80 value=?echo $saved_message_title;? where $saved_message_title is 1 Peter 5:7 Cast all your cares on Him for He cares about you --- note the When this is displayed on the screen $saved_message_title reads 1 Peter 5:7 I am assuming the closes the value= How may I echo this to the screen and have the full text be displayed, not just 1 Peter 5:7 ? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php His problem is in HTML, not PHP. Uses htmlspecialchars() or htmlentities() to convert special characters to HTML entities. The double quote will becomes quot; so that it can be display correctly. -- Sorry for my poor English. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on objects
- Original Message - From: Robert Cummings [EMAIL PROTECTED] To: Satyam [EMAIL PROTECTED] Cc: Deckard [EMAIL PROTECTED]; php-general@lists.php.net Sent: Thursday, October 05, 2006 2:16 AM Subject: Re: [PHP] Help on objects On Thu, 2006-10-05 at 07:04 +0200, Satyam wrote: I've seen you already had a good answer on the errors in the code so I won't go on that. As for OOP, the one design error you have is that you are asking for an action, not an object. You want to make SQL inserts, that is your purpose, and that is an action, which is solved by a statement, not by an object. There is no doer. Objects are what even your English teacher would call objects while describing a sentence. You are asking for a verb, you don't have a subject, you don't have an object. Of course you can wrap an action in a class, but that is bad design. Classes will usually have names representing nouns, methods will be verbs, properties adjectives, more or less, that's OOP for English teachers. Properties are very often nouns in addition to adjectives. For instance a linked list class will undoubtedly have noun objects referring to the current link, the next link, etc. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on objects [with reply]
i may be wrong, but your use of the class to me seems pointless... the reuse aspect of your database connection could be done with a simple include... maybe your need is different from what i suspect, being a beginner myself... here is what i do, and maybe the list can tell me if it would be better or worse for you... in a seperate php file define your database info... ?php //begin database information $hostname = localhost; $db_user = nerd_mysite; $db_pass = pepsi_is_good; $database = nerd__pepsi; $l = @mysql_connect($hostname, $db_user, $db_pass); @mysql_select_db($database, $l); //end database information ? and in the all of the files you would need this connection you would just include that file...and call the database with the variable $l. example: ? $nerdCheck = mysql_query(SELECT * FROM DrinkMorePepsi WHERE username = '$_POST[username]', $l) ? and this could easily be made into a function to allow for multiple databases, users passwords, ect if nothing else, at least tell me what you think about my way of doing this. - Original Message - From: Robert Cummings [EMAIL PROTECTED] To: Satyam [EMAIL PROTECTED] Cc: Deckard [EMAIL PROTECTED]; php-general@lists.php.net Sent: Thursday, October 05, 2006 2:16 AM Subject: Re: [PHP] Help on objects On Thu, 2006-10-05 at 07:04 +0200, Satyam wrote: I've seen you already had a good answer on the errors in the code so I won't go on that. As for OOP, the one design error you have is that you are asking for an action, not an object. You want to make SQL inserts, that is your purpose, and that is an action, which is solved by a statement, not by an object. There is no doer. Objects are what even your English teacher would call objects while describing a sentence. You are asking for a verb, you don't have a subject, you don't have an object. Of course you can wrap an action in a class, but that is bad design. Classes will usually have names representing nouns, methods will be verbs, properties adjectives, more or less, that's OOP for English teachers. Properties are very often nouns in addition to adjectives. For instance a linked list class will undoubtedly have noun objects referring to the current link, the next link, etc. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Testing people
how are you getting the answers? are they hard coded in html? are you pulling them from a database? if from a database, just order them randomly.. mysql_query(select answers from table where question = '10' ORDER BY RAND() ); i think this would randomize all of the results in the answer colum of the table. then you could use a while loop to display the answers with radio buttons on your test page. this may not be the best method and it will not work if your answers are html. - Original Message - From: Ryan A [EMAIL PROTECTED] To: php php php-general@lists.php.net Sent: Thursday, October 05, 2006 3:36 AM Subject: [PHP] Testing people Hey all, this is a two part question but I need just one solution: 1. Can you recommend a good testing software where the choices are multiple choice (cross a button or radio button) if nothing great out there... will make this myself so, on to point 2: 2. I have noticed if you are displaying 4 (a-d) choices and the answer for question 10 (for example) is always on choice B it kind of sticks in the head and students dont really read everything they just memorize the location of the answer (maybe unconsciously) and click that.. i have an idea of making the answers jump around for example: once the correct answer for question 10 is B, if you reload the page, it would be C, reload again and its A (chosen randomly...) (real) example 2: What has two legs: a: an elephant b: a dog c: a bird d: a cat C is the correct answer of course... but if you reload the page: a: a bird b: an elephant c: a dog d: a cat now A is the correct answer. I thought of having a hidden text box everytime for each question... but that can be quite easily found out... any other suggestions? Thanks! Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - All-new Yahoo! Mail - Fire up a more powerful email and get things done faster. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on objects [with reply]
yea, thanks for the input... but do you think my solution would be better for original poster? - Original Message - From: Dave Goodchild [EMAIL PROTECTED] To: benifactor [EMAIL PROTECTED] Cc: Robert Cummings [EMAIL PROTECTED]; Satyam [EMAIL PROTECTED]; Deckard [EMAIL PROTECTED]; php-general@lists.php.net Sent: Thursday, October 05, 2006 4:55 AM Subject: Re: [PHP] Help on objects [with reply] Re the last suggestion, ensure you keep those database details outside the web root (ie in a file called connect.inc for example) or if have to keep it there add a .htaccess file that prevents download of *.inc files. Also, avoid use of the error suppression operator (@). You need to see your errors. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] class usage
ok, about five minutes ago i decided to learn classes and delve into php's oop side. what i came up with was this... //start example code class newsletter { function send ($email,$subject,$message) { if ($email) { echo(the following message was sent to: $email br subject: $subjectbrbr $message); } else { echo(failure); } } } $new = new newsletter(); $new-send([EMAIL PROTECTED], test class, test class worked, i have passed and failed the test.); //end code example ..and this seems to work fine, i could easily add the mail function and insert real variables into send() but what i don't understand is i could also easily do this without a class... so i guess the real question is what are some real life examples of class usage and why is it used as opposed to regular non oop? thank you for any input into the subject that you may have.
Re: [PHP] class usage
thank you all for your input, and thank you richard for breaking that down nice and slow for me :) uhh, that was just me trying to see how a class works, and is by no means a real program and will never be. just as i was coding my first class i confused myself thinking that i could do the same stuff without classes and such... however i need to make trivial useless scripts to learn before i come across the need to use real classes and objects to avoid ending up lost and begging the list for help. any other comments would also be appreciated... thanks again. - Original Message - From: Richard Lynch [EMAIL PROTECTED] To: benifactor [EMAIL PROTECTED] Cc: php php-general@lists.php.net Sent: Friday, September 29, 2006 9:07 AM Subject: Re: [PHP] class usage On Fri, September 29, 2006 4:35 am, benifactor wrote: ..and this seems to work fine, i could easily add the mail function and insert real variables into send() but what i don't understand is i could also easily do this without a class... so i guess the real question is what are some real life examples of class usage and why is it used as opposed to regular non oop? thank you for any input into the subject that you may have. For something that small, using a class is ridiculous, bloated, over-engineered pointless exercise. Rather than type ridiculous, bloated, over-engineered pointless exercise in this email again, I'll simply dub that Wrong Answer and type that a lot. In fact, for almost *ANY* small/simple problem OOP is the Wrong Answer. OOP shines, however, in some large-scale usage: #1. One architect, many developers If you have ONE project architect cleanly map out a Plan in the form of a large class structure, with a clear and clean internal API, and a bunch of junior programmers to fill in the details, the Architect can use OOP with stub functions, just like you wrote above, to build the framework, and the junior programmers can fill in all the stubs. #2 Real-world parallels Sometimes when modeling real-world parallels (or even Virtual World parallels like game prototyping, windowing systems, etc) having OOP leads to a very natural readable maintainable code-base, as the operations and variables and the interaction between them mirrors to a large extent the operation and interaction between their real-world counterparts. The biggest problem in OOP, in my experience, is that you have many developers, like yourself, who begin using OOP solely because they are told that it's better Many of these developers then go on to write *BAD* OOP code, for all the wrong reasons, in all the wrong places, to solve trivial problems with the Wrong Answer. Many of these developers continue to use the Wrong Answer over and over, and never actually utilize any of the strengths of OOP, but instead train themselves to misapply OOP. Their code works it's just oftentimes the Wrong Answer Unfortunately, learning to use OOP correctly is a long-term process, and you have to do a bunch of trivial things with the Wrong Answer just to figure out how it works -- Which means you really should re-do them as non OOP, or be doing them solely as a means of learning and not throwing them into Production. Alas, this is not how 99% of OOP code in Production ends up in Production... All too often, it's the Wrong Answer that gets thrown into Production. This is not meant as a dis of the great OOP code out there. I've seen some very very very nice OOP systems in the past -- in Lisp, to solve large-scale problems. In PHP, to spit out a web page in under 1.7 seconds, not so much. :-) I'm sure somebody out there has a GREAT PHP web application with a complex backend all in OOP. So far, all I've seen is Wrong Answer. YMMV -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] USB Question Not PHP Related, so if you don't want to read this you don't have to
you should try to search for a headset with a splitter. i dont know if this would work for your needs, but it would allow multiple connectons and require only one port. - Original Message - From: Jay Blanchard [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Wednesday, September 13, 2006 4:59 AM Subject: [PHP] USB Question Not PHP Related, so if you don't want to read this you don't have to I generally would not do this, but I have an urgent need and this group has seen everything; I need two USB ports on a system to have the same channel. I continue to STFW but have not come upon something like this yet. The application is for softphones in a call center environment, the headsets to be used are USB headsets...having two USB ports on the same channel would allow supervisors to plug-in and listen to a call with a call center rep. Anyone heard of anything like this? I appreciate any clues and nuggets. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail sending program (beginner)
i don't really understand what your trying to do here but if im correct there is a much easier way... if you are trying to make a newletter sign up this is simple. there is no reason to send the email to the database simply have the enter thier email address, use regex to check it, if it passes that test, send it and a uniqe conformation number to a database, and use mail() to send them the conformation information with the link to the confirm page. they then click on the link to confirm.php or whatever and it will check the database for that email or number... if they are both there and the both match it will erase it from the confirm database and send the info to the newsletter database. i will give you an example... //start index.php or news_signup.php or something of the sort... ?php //first we define the function for the email check... function is_valid ($email) { if (eregi(^[_a-z0-9-]+(\.[_a-z0-9-]+)[EMAIL PROTECTED](\.[a-z0-9-]+)*(\.[a-z]{2,3}) $, $email)) { return true; } } //check to see if the signup form button was pressed and perform tests on the form data.. if ($HTTP_POST_VARS[ADD_USER]) { if (!$HTTP_POST_VARS[email]) { $e = error! you must enter your email address!; } else { if (!is_valid($HTTP_POST_VARS[email]) { $e = error! your email address is invalid!; } else { //all the tests passed at this point, so we make that conf # i talked about... $conf = uniqid(nuser); //now we eneter all the information in to a database called add that has three feilds.. auto_increment id. email. confid. mysql_query(insert into add (id, email, confid) VALUES (null, '$email', '$conf')); //now we send the email $to = $email; $subject = 'Your Newsletter subscription...'; $message = Hello $email, your registration is almost complete! all you have to do now is confirm your registration. to do this simply click on this link: a href=\http://yoursite.com/newsletter/confirm.php?confid=$conf\;Complete Registration Now/a or, copy and paste this into your web browser: www.yoursite.com/newsletter/confirm.php?confid=$conf brbrbPlease Note: your resgistration will expire in exactly 24 hours from when you clicked the register button, so please confirm your registration now!/b; $message = wordwrap($message); $headers = 'From: [EMAIL PROTECTED]' . \r\n; $headers .= 'MIME-Version: 1.0' . \r\n; $headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n; mail($to, $subject, $message, $headers); $e = congratulations you have signed up! You should recieve an email shortly to confirm.; } } } else { //now we actually display the form ? form method=post action=whateveryoucallit.php email:br input type=text name=email value=?php echo($email); ? length=35br input type=submit name=ADD_USER value=SIGN UP! /form ?php //now we wnd the orginal php block } //now we dipslay the error message if there was any... if ($e) { echo($e); } ? this is the whole first page. simple. not too many languages. now the confirm page. //start confirm.php or whatever. ?php //first we make sure they got to this page by email, making sure the variable $conf is set if (!$conf) { $e = (Sorry, you must have an id in order to complete the registration... please click on or copy and paste the link from your email into your web browser.. thank you - staff); } //now we make sure that the confid is in the database else { $cc1 = mysql_query(SELECT * from add where confid = '$conf') or die(mysql_error()); $ccc1 = mysql_fetch_array($cc1); if (!$ccc1) { $e = (Sorry, The id you have enterd does not match any of our records...you may have already confirmed your email - staff); } //grab the data where the ids match and enter the in to the new database else { $query = mysql_query(select * from conf where confid = '$conf'); while ($d = mysql_fetch_array($query)) { $email = $d[email]; mysql_query(insert into users (id, email) VALUES (NULL, '$email')) or die(mysql_error()); //delete from the conf database mysql_query(delete from conf where conf = '$confid') or die(mysql_error()); $s = (Congratulations b$email/b, you have successfully signedup... you will now get our monthly emails...); } } } } if ($e) { echo(bcenter$e/b/center); } if ($s) { echo(bcenter$s/b/centerbrbcenter$s1/b/centerbrcenter bYou will now be redirected to login.../b/center); } ? this is not perfect, but should give you an idea of what your doing and a different way (possibly better) of doing this. - Original Message - From: aci india [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Friday, June 09, 2006 10:24 PM Subject: [PHP] Mail sending program (beginner) Dear group, Description: Following is the code which I tried for learning propuses. It is a mail sending program which checks weather the user enters a correct mail id If he enters the correct mail ID then user name and e-mail will get stored in the mysql data base table. After getting stored then mail will sent to the
Re: [PHP] Delete
when you insert each blog into your database, im assuming your not doing this by hand each and every time, assign each blog an id. in the place you want to delete the blog entries, list all of the blogs titles and ids. and then use mysql(delete); example: ? //create a variable for the delete blog entry of you control panel if ($view == delete_blog) { //this should be the value of your submit button if ($deleteBlog) { //this is the value of the blog entries to delete if (!$idblog) { //this is your error message, to be displayed if no blog was chosen to delete $de = font face=tahoma color=black size=1You Need To Choose a post to delete/font; } else { //list the values of the array in which all the blog entries you would like to delete are $delBlog = implode(,, $idblog); //do the actual deletion mysql_query(delete From blogs where id IN($delBlog)) or die(mysql_error()); //display the succesfull message if the blog entries were deleted echo(font face=tahoma color=black size=1bcenterblog(s):/b $delBlog bhas/have been deleted;/b/b/center); //now we display the blog entries //plus the sucsessfull message ? form method=post ?php $gn = mysql_query(Select * FROM blogs); while ($d = mysql_fetch_array($gn)) { ? INPUT TYPE=checkbox NAME=idBlog[] VALUE=? echo($d[id]); ?? echo(font face=tahoma color=black size=1bPost id:/b $d[id]b;/b bPost Title:/b $d[title]b;/b bPosted by:/b $d[poster]b;/bbr); ? ?php } ? brbrinput type=submit name=deleteNerd value=Delete class=button /form ?php } } else { //display blog entries only ? form method=post ?php $gn = mysql_query(Select * FROM blogs); while ($d = mysql_fetch_array($gn)) { ? INPUT TYPE=checkbox NAME=idBlog[] VALUE=? echo($d[id]); ?? echo(font face=tahoma color=black size=1bPost id:/b $d[id]b;/b bPost Title:/b $d[title]b;/b bPosted by:/b $d[poster]b;/bbr); ? ?php } ? brbrinput type=submit name=deleteNerd value=Delete class=button /form ?php } ? this is a very rough example, however you should catch the drift, make your id an array, implode that array and delete all the array data from the database. - Original Message - From: George Babichev [EMAIL PROTECTED] To: PHP General list php-general@lists.php.net Sent: Saturday, June 03, 2006 6:40 PM Subject: [PHP] Delete Hello everyone! I wrote a blog application, but now for the admin panel, i am trying to add a feature to delete blog posts. It would show the title of the post next to it, and have a delete link which would delete it. How would I do this? I mean if I have multiple blog entry's, how would I delete them without using php my admin? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql and php
i was wondering what is the most secure way to use mysql in php. is there a certain way it should be done or a way that is more secure than another? iv'e seen it done many ways and was wondering if it was just preference or a if there was a reason behind it. if you guys could post some examples of how you do it and why maybe you could help me understand or know of an article or tutorial on the subjecti would appreciate it.
Re: [PHP] how to reload a PHP page via PHP code
i reload my pages with a function using a meta tag... ?php // $sec is the amount of seconds you want to wait before it redirects //$url id the pace you want it to redirect to function redirect ($sec, $url) { ? meta http-equiv=refresh content=?=$sec;?;URL=?=$url;? ?php } //to use to refresh a page $url = $_SERVER['PHP_SELF']; redirect(0, $url); ? - Original Message - From: Jay Blanchard [EMAIL PROTECTED] To: Alain Roger [EMAIL PROTECTED] Cc: PHP General List php-general@lists.php.net Sent: Friday, April 14, 2006 9:45 AM Subject: RE: [PHP] how to reload a PHP page via PHP code [snip] Sorry, but i do not find it in my PHP manual :-( [/snip] http://www.php.net/manual/en/reserved.variables.php It is actually the first one mentioned on the page. :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] deleting muliple feilds from a table using an array
example code: //implode the value of the submitted form //$del will look like 38, 40, 43 $del = implode(,, $idd); //create query for the deletion of values from submited form $query = delete From news where id = '$del'; //execute query mysql_query($query) or die(mysql_error()); //echo sucess message echo(bcenterThe Post has been deleted.../b/center); here is what my problem is... This code will only delete the first value of $idd. what i think is wrong is i have the incorrect syntax to delete multiple feilds from a table if some one can help me it would be greatly appreactiated.
Re: [PHP] deleting muliple feilds from a table using an array
thanks all, very helpful! - Original Message - From: Brady Mitchell [EMAIL PROTECTED] To: benifactor [EMAIL PROTECTED]; php php-general@lists.php.net Sent: Friday, March 24, 2006 1:21 PM Subject: RE: [PHP] deleting muliple feilds from a table using an array -Original Message- example code: //implode the value of the submitted form //$del will look like 38, 40, 43 $del = implode(,, $idd); //create query for the deletion of values from submited form $query = delete From news where id = '$del'; //execute query mysql_query($query) or die(mysql_error()); //echo sucess message echo(bcenterThe Post has been deleted.../b/center); here is what my problem is... This code will only delete the first value of $idd. what i think is wrong is i have the incorrect syntax to delete multiple feilds from a table if some one can help me it would be greatly appreactiated. $query = delete From news where id IN($del); Take a look at http://dev.mysql.com/doc/refman/5.0/en/where-optimizations.html. The user comments are helpful. Brady -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mysql Rows
- Original Message - From: Robert Cummings [EMAIL PROTECTED] To: tedd [EMAIL PROTECTED] Cc: PHP-General php-general@lists.php.net; benifactor [EMAIL PROTECTED]; Murray @ PlanetThoughtful [EMAIL PROTECTED]; Anthony Ettinger [EMAIL PROTECTED] Sent: Saturday, March 04, 2006 9:41 AM Subject: Re: [PHP] Mysql Rows On Sat, 2006-03-04 at 09:14, tedd wrote: planetthoughtful wrote: But, too often I've seen people new to database design not liking 'gaps' because 'user1' will have a unique id of '1', while 'user2' will have a unique id of '6' because the records associated with unique ids '2' through '5' were deleted during testing, and so on. So, they feel that 'user2' should have a unique id of '2', ignoring the fact that that's not a unique id at all, if you had id '2' associated with another record at some point. And, Anthony wrote: I remember the days where i'd clear a database after testing to keep the auto_increment inline, but eventually, you will get out of sync on that, so it's not a reliable way of keeping a numerical sequence. Well... I'm one of those people who don't like gaps. I understand that if the dB is relational, then you shouldn't be concerned about gaps. Gaps are only perceived from a perspective of an artificial ordering system -- who knows where the data actually is in memory or on disk. However, when I'm working with a flat dB and want to step through the records to do editing, I like the records to be in order based upon an id (i.e., Record 1, Record 2, Record 3, and so on). I use an auto_increment unique id for this. It's not a big problem for me to keep the records in order either. Whenever I delete a record, I simply follow with: $dbQuery = ALTER TABLE $dbtable ; $dbQuery .= DROP id, ; $dbQuery .= ADD id INT UNSIGNED NOT NULL AUTO_INCREMENT,; $dbQuery .= AUTO_INCREMENT = 1; $result = mysql_query($dbQuery) or die(2. Could not renumber dB $dbQuery . mysql_error()); *LOL* I knew those MySQL people shouldn't have made the ALTER TABLE syntax available to just anyone. Gun -- foot -- *BLAM*. I hope to God you never get your hands on a real database with millions of entries. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' my reasoning for needing the users number in a database is this... i am going to be doing a lottery type thing where i grab a random number between 1 and the result of mysql_num_rows($result)... that is the reason the gaps matter. the while loop didn't work for me so if anyone could help me out on how to get this number i would aprreaciate it. thank you in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mysql Rows
- Original Message - From: benifactor [EMAIL PROTECTED] To: Robert Cummings [EMAIL PROTECTED]; tedd [EMAIL PROTECTED] Cc: PHP-General php-general@lists.php.net; Murray @ PlanetThoughtful [EMAIL PROTECTED]; Anthony Ettinger [EMAIL PROTECTED] Sent: Saturday, March 04, 2006 2:29 PM Subject: Re: [PHP] Mysql Rows - Original Message - From: Robert Cummings [EMAIL PROTECTED] To: tedd [EMAIL PROTECTED] Cc: PHP-General php-general@lists.php.net; benifactor [EMAIL PROTECTED]; Murray @ PlanetThoughtful [EMAIL PROTECTED]; Anthony Ettinger [EMAIL PROTECTED] Sent: Saturday, March 04, 2006 9:41 AM Subject: Re: [PHP] Mysql Rows On Sat, 2006-03-04 at 09:14, tedd wrote: planetthoughtful wrote: But, too often I've seen people new to database design not liking 'gaps' because 'user1' will have a unique id of '1', while 'user2' will have a unique id of '6' because the records associated with unique ids '2' through '5' were deleted during testing, and so on. So, they feel that 'user2' should have a unique id of '2', ignoring the fact that that's not a unique id at all, if you had id '2' associated with another record at some point. And, Anthony wrote: I remember the days where i'd clear a database after testing to keep the auto_increment inline, but eventually, you will get out of sync on that, so it's not a reliable way of keeping a numerical sequence. Well... I'm one of those people who don't like gaps. I understand that if the dB is relational, then you shouldn't be concerned about gaps. Gaps are only perceived from a perspective of an artificial ordering system -- who knows where the data actually is in memory or on disk. However, when I'm working with a flat dB and want to step through the records to do editing, I like the records to be in order based upon an id (i.e., Record 1, Record 2, Record 3, and so on). I use an auto_increment unique id for this. It's not a big problem for me to keep the records in order either. Whenever I delete a record, I simply follow with: $dbQuery = ALTER TABLE $dbtable ; $dbQuery .= DROP id, ; $dbQuery .= ADD id INT UNSIGNED NOT NULL AUTO_INCREMENT,; $dbQuery .= AUTO_INCREMENT = 1; $result = mysql_query($dbQuery) or die(2. Could not renumber dB $dbQuery . mysql_error()); *LOL* I knew those MySQL people shouldn't have made the ALTER TABLE syntax available to just anyone. Gun -- foot -- *BLAM*. I hope to God you never get your hands on a real database with millions of entries. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' my reasoning for needing the users number in a database is this... i am going to be doing a lottery type thing where i grab a random number between 1 and the result of mysql_num_rows($result)... that is the reason the gaps matter. the while loop didn't work for me so if anyone could help me out on how to get this number i would aprreaciate it. thank you in advance. here is what i tried.. while ($d = mysql_fetch_array($query)) { $i = 0; while ($d[username] != $user) { $i++ } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mysql Rows
i need to find a way to find out what number of a row is in a database... for example: //this is the database Username: Chuck Password: adsasa Username: jimmy Password: adsf Username: stewart Password: dfds the information i need is what row jimmy resides on.. this is what i tried: function i_gun ($user) { global $username; $gun = mysql_query(select * from users); while ($d = mysql_fetch_array($gun)) { while($d[username] != $user) { $i = $i + 1; } } } but it always returns 1. can sombody tell me what i am doing wrong or point me in the right direction in the manual? plase and thank you
Re: [PHP] Mysql Rows
thank you. the table does have and id feild that auto increments, however if you delete a user there will be a gap between the users between which would not be what is not acurate enough. thank you for you help. simple fix. i should have caught it. - Original Message - From: Anthony Ettinger [EMAIL PROTECTED] To: benifactor [EMAIL PROTECTED] Cc: php php-general@lists.php.net Sent: Friday, March 03, 2006 3:52 PM Subject: Re: [PHP] Mysql Rows define $1 = 0 outside your loop. i'm curious why you are relying on row-order in the database? Typically you'd have a PRIMARY KEY auto_increment for something like this. On 3/3/06, benifactor [EMAIL PROTECTED] wrote: i need to find a way to find out what number of a row is in a database... for example: //this is the database Username: Chuck Password: adsasa Username: jimmy Password: adsf Username: stewart Password: dfds the information i need is what row jimmy resides on.. this is what i tried: function i_gun ($user) { global $username; $gun = mysql_query(select * from users); while ($d = mysql_fetch_array($gun)) { while($d[username] != $user) { $i = $i + 1; } } } but it always returns 1. can sombody tell me what i am doing wrong or point me in the right direction in the manual? plase and thank you -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parse Error
- Original Message - From: Ray Cantwell [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Tuesday, February 21, 2006 1:27 PM Subject: [PHP] Parse Error Hi all, I am a noob and super confused right now. I have some really simple code and i am getting an error that reads: *Parse error*: syntax error, unexpected T_VARIABLE in */var/www/mysql_up.php* on line here is the code: html headtitleTest MySQL/title/head body !-- mysql_up.php -- ?php $host=localhost $user=ray $password=* mysql_connect($host,$user,$password) ; $sql=show status; $result = mysql_query($sql); if ($result == 0) echo bError . mysql_errno() . : . mysql_error() . /b; else { ? !-- Table That Displays the results -- table border=1 trtdbVariable_name/b/tdtdbValue/b /td/tr ?php for ($i = 0; $i mysql_num_rows($result); $i++) { echo TR; $row_array = mysql_fetch_row($result); for ($j = 0; $j mysql_num_fields(result); $j++) {/ echo TD . $row_array[$j] . /td; } echo /tr; } ? /table ?php } ? /body/html I am really confused because i cannot see any obvious errors. any help would be appreciated. Ray. you need to add a ; to every variable you assign... you had: $host=localhost $user=ray $password=* it should be: $host=localhost; $user=ray; $password=*; also i belive a better way to get the result of your query would be mysql_connect($host, $user, $pass) or die(mysql_error()); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] archiving?
i have a question about what i beleive to be called archiving... i am building a news script and would like to limit post to be displayed per page i have done this successfully. what i am having probplems with is displaying the next set of news. here is my code: ?php include(core.php); session_start(); $gi = mysql_query(select * from news ORDER by id asc); while ($d = mysql_fetch_array($gi)) { $id = $d[id]; $title = $d[title]; $news = $d[news]; $poster = $d[poster]; $pdate = $d[date]; $ptime = $d[time]; ? b ui?php echo($title); ?/u/ibrbr p ?php $i = $i + 1; echo($news); ?brbr Posted By: ?php echo($poster); ?, On ?php echo($pdate); ? @ ?php echo($ptime); ? br ?php if ($nerd == bignerds) { echo(a href=\admin.php\Edit Post/a ); echo(nbsp; a href=\admin.php?view=delete_newsid=$iddelete=true\Delete Post/abrbr); } if ($i = 1) { break; } ? /b ?php } ? this gets it to stop after one post. i was thinking about setting a variable on the last post displayed, but to me this doesn't seem like the most logical way. if someone could point me in the right direction, or send me to a tutorial on the subject i would greatly appreaciate it... thank you in advance
[PHP] string size in bytes
can someone point me in the right direction... i need to know how many bytes are in a string example: $string = blah; string == how many bytes also i need to know how to find out how fast a page renders example; page rendered in 1.114 seconds any help would be greatly appreciated thank you