[PHP] htmlspecialchars
Hi, I wonder which is the better way to store data into database? 1. stor the data after we call htmlspecialchars with the data (means we store " as "e; in database) 2. stor the data in non encoded form and call htmlspecialchars whenever we want to display it. Foong -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: query question
hope this help // array of zip codes $zips = array(...); // can use implode() here if you want foreach($zips as $zip) { $zip_list = ",'".$zip."'"; } // take away the first comma $zip_list = substr( $zip_list, 1); $sql = "SELECT stores FROM store_table WHERE zip_code IN('$zip_list')"; $hdl = mysql_query($hdl); Foong Kelly Meeks <[EMAIL PROTECTED]> wrote in message 009c01c2bbf5$03496b00$6901a8c0@yourw92p4bhlzg">news:009c01c2bbf5$03496b00$6901a8c0@yourw92p4bhlzg... I've got an array of values, that I need to query against a database to see if any records have any of the values in the array - the array is a list of zip codes, and the database contains a list of stores. Basically i need to find what stores have zip codes in the array. I know that mysql doesn't support subquerys - is there a workaround for this kind of scenario? TIA, Kelly -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: valid MySQL result resource
put the following line after you call mysql_query(..), you should be able to see the error: echo mysql_error(); this line is very handy to see what's wrong with mysql related operation. Remember to delete it after debugging for security reasons Foong Brent Lee <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Here is another error I'm getting while trying to view my db. I copied > and pasted these statements from a pdf file I'm using to learn PHP but they > keep creating errors. > I am writing all your tips into my notes to try to keep my questioning > to a minimal. > > Warning: mysql_fetch_array(): supplied argument is not a valid MySQL > result resource in /home/xxx/public_html/Info/viewdb.php on line 8 > > > > > $db = mysql_connect('localhost', 'x', 'xxx'); > mysql_select_db('learndb',$db); > $result = mysql_query("SELECT * FROM personnel",$db); > echo ""; > echo"Full NameNick NameSalary"; > while ($myrow = mysql_fetch_array($result)) > { > echo ""; > echo $myrow["firstname"]; > echo " "; > echo $myrow["lastname"]; > echo ""; > echo $myrow["nick"]; > echo ""; > echo $myrow["salary"]; > } > echo ""; > ?> > > > > -- > > Thanks > __ > Brent Lee > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: globals off in function
instead of: global $smarty; $smarty]->assign("message", $message); try: $_GLOBAL['smarty']->assign("message", $message); Foong Michael Bevz <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, all!!! > I've such trouble: > ( register_globals = off ) > > in function i call to $smarty variable > " > function showLoginForm(){ > >global $db, $smarty; // $smarty = new Smarty in main code > > $smarty->assign("message", $message); // > " > and i receive this error message > " > Fatal error: Call to a member function on a non-object in > /usr/home/elastic.org/work/svyatoshin/system/common_func.php on line 22 > " > > Imho, globals don't working with "globals off", nut i can't find this in > manual. > > Who can help me? > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: htmlspecialchars
Thank you guys Foong Foong <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > I wonder which is the better way to store data into database? > 1. stor the data after we call htmlspecialchars with the data (means we > store " as "e; in database) > 2. stor the data in non encoded form and call htmlspecialchars whenever we > want to display it. > > Foong > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: sending array
I am not sure you can do it way, here is what i suggest test2.php?org[index-A]=&org[index-B]=.. you need to specify each var in you array in the query path. Danielle Van Gladbach <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > I am trying to send an array from one php to another: > > $org["index-A"]=1701; > $org["index-B"]=1209; > > print "test2\n"; > > But if I try to read te array in test2.php, I get "Warning: Variable > passed to each() is not an array ". > > Can anyone help me > Danielle > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Multiplication of double
have you try echo $price and $qty separately to check if they are correct? If they are correct, can you post you code? so we can take a look. Foong Cesar Aracena <[EMAIL PROTECTED]> wrote in message 01c2bfeb$cecbd5c0$7a00a8c0@NOTEBOOK">news:01c2bfeb$cecbd5c0$7a00a8c0@NOTEBOOK... Hi all, I guess this problem might sound childish for most of you, but I'm having it right now. I get two numbers from a FORM, one price and one quantity and I need to make a multiplication with them in order to store the total amount also as a double expression... I'm trying with: $totalprice = $price * $qty; but when I echo the, it gives me just plain old 0 (zero). Any suggestions? Thanks in advance, Cesar L. Aracena [EMAIL PROTECTED] [EMAIL PROTECTED] (0299) 156-356688 Neuquén (8300) Capital Argentina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Sessions
I used to have the same problem(sort of) I am not sure if my solution applies to you. Here is what i did, to pass session to one page to another you must call session_start(); ON EVERY PAGE to access registered session variables use the session super global array like: $_SESSION['userid']; Sorry if it's not relevant. Foong "Tim Thorburn" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > After a day and a half of pounding my head against the wall I believe I've > identified the source of the problem. When I create and register the > session in my login page - it does not carry forward to any other > pages. I've found this by going through several different tutorials for > making password protected areas using PHP and Sessions that I've found both > online and in books - all produce the same result on the server with > attitude - yet all work on all other servers I'm currently using for my > hosting. > > So, since this is an eCommerce site for my client and they're getting > increasingly impatient with the progress made I'm left with little choice > in this matter - as moving the site now would be unthinkable, and tech > support at the hosting company is less than stellar, and generally not in > English. Are there any obvious PHP settings that I'd need to adjust to > ensure that Sessions can be carried forward to additional pages? My only > other option now is to force my client to login to each screen in the admin > area (conceivably this could mean the client would need to log in to a > minimum of 8 different pages to observe their records and make changes to > the site). > > I'm at the point of desperation and sleep deprivation ... If there are no > obvious PHP settings that need to be altered - what else could be producing > this problem? > > Thanks > -Tim > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Multi-Byte String Functions
I never use mg_* function b4. You should try post you question on php.i18n. bcos it is the newsgroup dedicated for localization Foong "Sadeq Naqashzade" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi all, > I'm newbie of PHP. Can any one help me and explain how can use Multi-Byte > String Functions? > My national language is Farsi and I force to use UTF-8 for my works. but I > have several problem when I need use it in PHP. I think Multi-Byte String > Functions are designed for some ones like me. but I can not use it :-( > > I'm using Windows 2000 and Apache 1.3 plus PHP installed as module on my PC. > > -Sadeq > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Disable pic copy/save?
try this article http://www.devarticles.com/art/1/265 However it is not perfect. Foong "Anthony Rodriguez" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi! > > A client wants to test market two versions of an advertising but wants to > disable the users' ability to copy/save the ads (right click, copy/save). > > How can this be done in PHP? > > Thanks! > > Anthony F. Rodriguez > ([EMAIL PROTECTED]) > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: textarea new line
u can use nl2br() to convert \n to tags b4 echo the string in textarea. Foong "Neil M" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Adi wrote: > > i want to add in textarea a string with new line tag in it. how to do that? > > > > my try: > > $string="-line1n\ -line2 n\-line3"; > > echo "$string"; > > > > but i see a single line instead of: > > -line1 > > -line2 > > -line3 > > > > tx in advance for any help > > > > Hello > > For a new line in a text area you cant use html 's > > You need to use either \n OR \r\n > > Thanks > > Neil > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: submit button
can i have a peek on your diki.php? I didn't see any attachment. Foong "Diksha Neel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi everybody, > > i have a PHP script by name registration.php > in which i have a submit button at the bottom. > the form in this script is sent to p.php by "GET". > but on clicking the submit button, nothing happens > attaching registration.php. > > p.php has only the following: > echo "hi how are u"; > ?> > > please help, > diksha. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: submit button
sorry, I really didn't seen any attachment in any of your post. can you paste it in your next post? foong "Diksha Neel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi everybody, > > i have a PHP script by name registration.php > in which i have a submit button at the bottom. > the form in this script is sent to p.php by "GET". > but on clicking the submit button, nothing happens > attaching registration.php. > > p.php has only the following: > echo "hi how are u"; > ?> > > please help, > diksha. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SUBMIT
OK sorry i miss this post. looking at you code. I guess there are mismatch of opening and closing tags. In HTML double slashes // is not a comment. when you do something like // The tag wont get commented use: to comment a html tag out side php scope. Foong "Diksha Neel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > dear all, > > hi! > i have a php page by name diki.php which i have pasted below. > i have removed the irrelevant code because of the size limit of > the email. > in this page is a submit button at the end. the form in > which this button is placed is by "get" sent to p.php which > has only the following contents: > > echo "hi"; > ?> > > but when i click on submit button i am not getting > connected to p.php. > strange! > > any help would be greatly appreciated. > thanks! > best wishes from India. > diksha. > > > > > > > Registration Form > > function allow() > { > if(document.f1.ocity.value!="Others") > document.f1.city1.blur(); > } > function allow1() > { > if(document.f1.orcity.value!="Others") > document.f1.rcity1.blur(); > } > function rallow() > { > if(document.f1.ostate.value!="Others") > document.f1.state1.blur(); > } > function rallow1() > { > if(document.f1.orstate.value!="Others") > document.f1.rstate1.blur(); > } > function adjust() > { > pbus1=document.f1.pbus.options[document.f1.pbus.selectedIndex].value; > if(pbus1=="accounting") >{ > document.f1.interest1.checked=true; > } > if(pbus1=="advertising") >{ > document.f1.interest2.checked=true; > } > if(pbus1=="agriculture") >{ > document.f1.interest3.checked=true; > } > if(pbus1=="arts") >{ > document.f1.interest4.checked=true; > } > > > } > function check(na) > { > var st=na;st1=st.length; > for(i=0;i<st1;i++) > { > if((st.charCodeAt(i)<48)||(st.charCodeAt(i)>57)) >{ return false; >break; } > } > } > function checke(id) > { > r1=id; r2=r1.indexOf('@',0);r3=r1.indexOf('.',0); > r4=r2+1; r6=r1.length -1; > rlen1=r1.length; >rcont=0; > rstart=0; > while(rstart<rlen1) > { >rpos=r1.indexOf("@",rstart); >if(rpos==-1) > break; >rcont=rcont+1; >rstart=rpos+1; > } >if(rcont>1) > { > return false; > } > > > r5=r1.indexOf(null,r6); > if((r1.indexOf('@',1)==-1)||(r2>r3)||(r3==r4)||(r3==r6)||(r1.indexOf("@",0)= =-1) > > ||(r1.indexOf(".",0)==-1)) >{ return false;} > } > function validation() > { > if(document.f1.yname.value=="") > { > alert("Please enter your > name");document.f1.yname.focus();return false; > } > if(document.f1.cname.value=="") > { > alert("Please enter company > name");document.f1.cname.focus();return false; > } > if(document.f1.cat.value=="- -Select a Category- -") > { > alert("Please select Category ");document.f1.cat.focus(); > return false; > } > if(document.f1.pbus.value=="- -Select Primary Business- -") > { > alert("Please select Primary Business > ");document.f1.pbus.focus();return > > false; > } > if(document.f1.bemail.value=="") > { > alert("Please enter business > email");document.f1.bemail.focus();return > > false; > } > else > { > cbemail=checke(document.f1.bemail.value); > if(cbemail==false) > { > alert("Enter correct Business Email > > Address");document.f1.bemail.focus();return false; > } > } > if(document.f1.pemail.value=="") >{ >alert("Please enter personal > email");document.f1.pemail.focus();return > > false; >} > else > { >cpemail=checke(document.f1.pemail.value); >if(cpemail==false) > { > alert("Enter correct Personal Email > > Address");document.f1.pemail.focus();return false; > } > } > if(document.f1.pass.value=="") >{ > alert("Please enter > password");document.f1.pass.focus();return false; >} >else > { > if(document.f1.pass.value.le
Re: [PHP] stripping slashes before insert behaving badly
if Magic_quotes_gpc in you php.ini is set to 'on', php will automatically escape(add slashes) for you. Foong "Charles Kline" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > John, > > You are right, something was adding the additional slash. I removed the > addslashes() and it fixed the problem. Something I am doing must > already be handling that... will step through the code AGAIN and see if > I can find it. > > - Charles > > On Monday, March 17, 2003, at 12:19 PM, John W. Holmes wrote: > > >> I am inserting data from a form into a mySQL database. I am using > >> addslashes to escape things like ' in the data input (this is actually > >> being done in PEAR (HTML_QuickForm). > >> > >> The weird thing is that the data gets written into the table like: > >> what\'s your problem? > >> > >> WITH the slash. I am not sure what to modify to fix this so the > > literal > >> slash is not written. > > > > You're running addslashes() twice, somehow. Magic_quotes_gpc is > > probably > > on and you're escaping the data again. I would think PEAR would account > > for that, but I guess not. > > > > ---John W. Holmes... > > > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy > > today. http://www.phparch.com/ > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Detecting if GET field is Numeric or Alpha numeric
Helo, use is_numeric($str) to check whether a string contains all numeric values. Foong "Stephen Of Blank Canvas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi Everyone, > > Does anyone know if it is possible to check the values of a $_GET field > and see if the submitted data is numeric or contains any letters. > > What I want to do is allow users to link to a record in a MySQL db using > the record id's and the values of the name field. > > www.domain.com/showlisting.php?town=1 and > www.domain.com/showlisting.php?town=London > > Both would work by performing a search on different fields in the MySQL > SELECT statement. Just an idea to make thing easy for users, any help > appreciated. > > Thanks > > Stephen > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] running PHP through command shell
Does anybody knows why I get call to undefined function for mysql_connect when running PHP through command shell. but it works fine when accessing the script through web browser. Foong -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Informix
Hello any idea how can i fix this problem when I compile php with informix ERROR: /opt/informix/lib/esql/libifos.so: the use of `mktemp' is dangerous, better use `mkstemp' Foong -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Retrieving newly created ID from MySQL?
hello just call: mysql_insert_id(); right after you execute a insert statement Foong "Ben Cheng" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If I have a MySQL table with an auto-incrementing ID field, is there an > easy way to retrieve the new ID after I insert a new row into the > table? For example, if I insert a row into a table with ID, Title, & > Content fields, is there a way I can get the ID value without doing a > separate select where the Title & Content fields are equal to the > values I just inserted? > > -Ben > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with PHP
can i have a peek on you code Foong "Jan Navratil" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > > Hallo, > > > > i have problem with running PHP4.3.1 on Apache1.3.19 on W2K. > > > > I instaled everithng by install.txt. Is posible to load easy php pages but > > when i want to Recieve data from form it does not wrok. > > > > Please help me > > > > Best regards Honza Navratil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date math question
hi, $start = mktime ( 0, 0, 0, 1, 1, date['Y']); // first day of this year $end = mktime ( 0, 0, 0, 12, 31, date['Y']); // last day of this year then select all record where timestamp >= $start and timestamp <= $end should do the job Hope this helps Foong "Charles Kline" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Okay cool. > > This leads me to another question. If I have stored the date as an > epoch then is there a way using PHP and MySQL to say find all the > records that have been added this YEAR (not last 365 days)? > > Thanks > Charles > > > On Friday, March 28, 2003, at 12:31 AM, Leo Spalteholz wrote: > > > On March 27, 2003 09:15 pm, Charles Kline wrote: > >> I am storing my dates as unix timestamp (epoch). Am I right in > >> assuming that if I need to add or subtract days from this it is > >> done in seconds? > > > > yes > > > > > > -- > > 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] date math question
sorry typo error should be: date('Y') Foong "Foong" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi, > > $start = mktime ( 0, 0, 0, 1, 1, date['Y']); // first day of this year > $end = mktime ( 0, 0, 0, 12, 31, date['Y']); // last day of this year > > then select all record where timestamp >= $start and timestamp <= $end > > should do the job > Hope this helps > > Foong > > > > > "Charles Kline" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Okay cool. > > > > This leads me to another question. If I have stored the date as an > > epoch then is there a way using PHP and MySQL to say find all the > > records that have been added this YEAR (not last 365 days)? > > > > Thanks > > Charles > > > > > > On Friday, March 28, 2003, at 12:31 AM, Leo Spalteholz wrote: > > > > > On March 27, 2003 09:15 pm, Charles Kline wrote: > > >> I am storing my dates as unix timestamp (epoch). Am I right in > > >> assuming that if I need to add or subtract days from this it is > > >> done in seconds? > > > > > > yes > > > > > > > > > -- > > > 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] Re: magic quotes
Hello, When magic_quotes_gpc is on, addslashes() will be automatically applied on all data from GET, POST, COOKIES by PHP. When magic_quotes_runtime is on, addslashes() will be automatically applied on all data collected form database (ex: when you execute a SELECT statement). Therefore when magic_quotes_runtime is on, you need to use stripslashes() on data colected from database. It is not only apply to data collected from database, others as well. I believe there is a details guide in the php documentation at php.net. Foong "Justin French" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all, > > Can I just have a quick head check on magic quotes runtime (&gpc)? > > I have them both set to Off currently, and my pages work fine. However, > when I set them to on, I end up with slashes throughout the mysql data. > > Is this the expected behaviour? Seems counter-intuitive to me, but I've > never really cared about it 'till today, because i've never had a problem!! > > > What is a common setting for these two directives, so that I can have my LAN > server *reasonably* "normal". > > TIA > Justin > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php