[PHP] Sync CSV files with MySQL Database.
Hello mates, Perhaps this seems to be a silly question, but it is not to me, here is the scenario: I know how to import CSV files with PHP to a MySQL database, the thing is, that CSV file is automatically feed by a third-party application, I want to do something to add just the new records, not all the records again. Any idea or example, will be really appreciated. Thanks! -- Carlos Sura.- www.carlossura.com www.carlossura.com/blog
[PHP] PHP code problem with pages
Hello Mates, Maybe my subject line is not descriptive as I wish, but I just did not know how to put on it. I have the following problem, I'm using jQuery to make a slide effect (horizontal), everything seems to be working find, but I have to add a mask with a white color background, I did this by CSS, now I have 6 pages in total, this is managed by wp anyway, it shows the white bakground mask in every page, and I want it to show in every page but not the home page; since I'm using a slider effect and a container, it became very difficult to me, maybe any of you can explain me a way to a easy fix, I will show you the lines of code: div id=wrapper div id=mask ?php $pages = list_all_pages(); ? ?php //Get first and last page ID $cnt = 0; foreach($pages as $page) { $post_keys = get_post_custom_values('section_id', $page-ID); $post_key[$cnt] = $post_keys[0]; $cnt++; } ? ?php $cnt = 0; foreach($pages as $page) { $post_keys = get_post_custom_values('section_id', $page-ID); ? div class=item ?php if(($jxfs_transition == 'horizontal_vertical' $cnt%2 == 0) || ($jxfs_transition == 'horizontal')) { echo 'fl';} ? id=?php echo $post_keys[0]; ? div class=content ?php $page_content = get_page($page-ID); ? ul class=container //This is the container with the white background. li class='grid_820' ?php echo do_shortcode($page_content-post_content); ? /li As you can see, I'm using this for all pages, I was trying to use another template-code to tell wordpress that home page uses another page as home, but it does not work for some reason. Anyway, help will be appreciated. -- Carlos Sura.- www.carlossura.com
[PHP] dealing with this code $_POST['custom´]
Hello mates, My problem is very simple, I want to save the forwards emails in some contact list so I'm saying what list in the following code: } else { $saving_list = $_POST['custom'] == 'FR' ? 148 : 147; So, what I'm actually doing is: } else { $saving_list = $_POST['custom'] == 'FR' ? 152 : 148 : 147; But, it doest make anything, also in Windows with Dreamweaver it says: syntax error I'm not an advanced user of PHP, but I really don't get why adding just another id (of a contact list) would be a syntax error if I only use 148:147 it works fine! Any help would be appreciated. Regards -- Carlos Sura.- www.carlossura.com
RE: [PHP] Re: Do you have some standard for defined the variable in program language?
Hello Jordan, As he said... You may use any. [1] Which one is correct in any given project or organisation is different question. Yeah, he got a point there. Regards, Carlos Sura. To: php-general@lists.php.net From: php-gene...@garydjones.name Date: Wed, 28 Jul 2010 11:16:54 +0200 Subject: [PHP] Re: Do you have some standard for defined the variable in program language? Jordan Jovanov wrote: I start to write PHP script and all veritable a defined without some rules. I want to ask to you somebody know how is correct do different some variable. Like from next three variable who is correct: $firstname $FirstName $firstName $first_name etc. They all are[1]. The great thing about standards is that there are so many to choose from. [1] Which one is correct in any given project or organisation is different question. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with template file and email
Hello Joey, No problem, I'm glad you got it working now. Any other question. Use php-list. Regards, Carlos Sura. From: j.hendrick...@comcast.net To: carlos_s...@hotmail.com Subject: Re: [PHP] Help with template file and email Date: Sat, 24 Jul 2010 08:29:03 -0500 Hi Carlos, I wanted to thank you for all your help!! In the function I had to use a foreach() to get the email. Then put the $_GET['email'] in when I called the function. Finally got it! Thank you for your help!! Joey. - Original Message - From: Carlos Sura To: j.hendrick...@comcast.net Cc: php-general@lists.php.net Sent: Tuesday, July 13, 2010 10:48 AM Subject: RE: [PHP] Help with template file and email Let me get this right... $mymail // If you put an email adress it works, right. You are calling variable $mymail... But, what does contain that var? You are calling $mymail, there has to be a database, or something of those 10 mails you said. -If i'm getting you the point right- If not, my mistake. Or you might use something like this: ?php // mail list $to = 'yourma...@example.com' . ', '; $to .= 'yourma...@example.com'; If my answer is wrong for you. Plrease reffer to: http://docs.php.net/manual/en/function.mail.php -as Richard said.- From: rquadl...@gmail.com Date: Tue, 13 Jul 2010 15:02:14 +0100 To: j.hendrick...@comcast.net CC: php-general@lists.php.net Subject: Re: [PHP] Help with template file and email On 13 July 2010 14:56, Joey Hendricks j.hendrick...@comcast.net wrote: Hello, I have been working on a birtday invite program. The form takes 10 names and 10 email addresses. I think the problem is the $to variable in my function. I get this warning-Warning: mail() [function.mail]: SMTP server response: 550 5.5.0 f domain name required in. Could someone help me with this my email is j.hendrick...@comcast.net Thank you so very much! ?php mail(' j.hendrick...@comcast.net', 'Test email', 'This is a test email'); ? and I get the following entry in my PHP's mail.log ... mail() on [-:2]: To: j.hendrick...@comcast.net -- Headers: Pretty simple stuff. http://docs.php.net/manual/en/function.mail.php Regards, Richard. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Get a new e-mail account with Hotmail - Free. Sign-up now. _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now
RE: [PHP] help using phpadmin
Hello Isaac Lee, I don't remember well, but I think this is the way to do it in Windows. You can try this: Start -- Run cmd // Write it and press enter key. It will show you a MS-DOS window, Write there: mysql now: mysql cd c:\location\mysql\bin Then you might try: mysqladmin -u root password new_password Now type: mysql -u root -p Write your new password now :) If none of this work... Please show me your ini* file. If you can't show me your ini* file please reffer to: http://search.mysql.com/search?q=Resetting_permissions.htmllr=lang_en Regards, Carlos Sura. Date: Mon, 19 Jul 2010 12:24:26 -0400 From: rhinecant...@gmail.com To: carlos_s...@hotmail.com CC: php-general@lists.php.net Subject: Re: [PHP] help using phpadmin im using windows. On Mon, Jul 19, 2010 at 12:23 PM, Isaac Lee rhinecant...@gmail.com wrote: thanks carlos, but where would i enter that command? and i tried editing the php.ini file but that didn't accomplish anything. isaac On Mon, Jul 19, 2010 at 1:29 AM, Carlos Sura carlos_s...@hotmail.com wrote: Hello Isaac Lee. Are you running on Linux or Windows? You might try: mysql SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’yourpassword’); Then restart your service -if needed- If not... Try to edit config.inc.php file. Regards, Carlos Sura -Original Message- From: Isaac Lee [mailto:rhinecant...@gmail.com] Sent: domingo, 18 de julio de 2010 10:34 p.m. Cc: php-general@lists.php.net Subject: [PHP] help using phpadmin this is the second time that i have made an account and set the password. then when i try to reaccess phpadmin, it shows this message: Error MySQL said: #1045 - Access denied for user 'root'@'localhost' (using password: NO) What am supposed to do so that my regain access to phpadmin? edit the php.ini file? isaac -- 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 _ We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now http://clk.atdmt.com/UKM/go/195013117/direct/01/
RE: [PHP] help using phpadmin
Hello Isaac Lee. Are you running on Linux or Windows? You might try: mysql SET PASSWORD FOR root@'localhost = PASSWORD(yourpassword); Then restart your service -if needed- If not... Try to edit config.inc.php file. Regards, Carlos Sura -Original Message- From: Isaac Lee [mailto:rhinecant...@gmail.com] Sent: domingo, 18 de julio de 2010 10:34 p.m. Cc: php-general@lists.php.net Subject: [PHP] help using phpadmin this is the second time that i have made an account and set the password. then when i try to reaccess phpadmin, it shows this message: Error MySQL said: #1045 - Access denied for user 'root'@'localhost' (using password: NO) What am supposed to do so that my regain access to phpadmin? edit the php.ini file? isaac -- 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] user login and access + headers already sent
Hello mates, I'm developing a user registration and access level system... And I wonder... Is there any way to avoid to put code in every header page? Because, almost every page contains javascript, so almost every page cotains html tags... And its annoying to look at this: Warning: session_start(): Cannot send session cache limiter - headers already sent So, I'm wondering, is there any other way to avoid put code in every page? or... another way to avoid that kind of error. Thank you. _ Got a cool Hotmail story? Tell us now http://clk.atdmt.com/UKM/go/195013117/direct/01/
RE: [PHP] user login and access + headers already sent
Hello Richard, Thank you for your answer, I'm looking now... Kranthi, seems to be a pretty good solution, I will give it a try. Thank you. From: kranthi...@gmail.com Date: Thu, 15 Jul 2010 21:24:15 +0530 To: rquadl...@googlemail.com CC: carlos_s...@hotmail.com; php-general@lists.php.net Subject: Re: [PHP] user login and access + headers already sent i prefer using a template engine like smarty http://www.smarty.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Do you have a story that started on Hotmail? Tell us now http://clk.atdmt.com/UKM/go/195013117/direct/01/
RE: [PHP] user login and access + headers already sent
Hello paul, thank you for your answer. I'm already fixing all my mess with your suggestions. It is nice to know where to ask to get a good answer. Regards, Carlos Sura. Date: Thu, 15 Jul 2010 12:22:23 -0400 From: pa...@quillandmouse.com To: php-general@lists.php.net Subject: Re: [PHP] user login and access + headers already sent On Thu, Jul 15, 2010 at 04:56:50PM +0100, Ashley Sheridan wrote: On Thu, 2010-07-15 at 15:38 +, Carlos Sura wrote: Hello mates, I'm developing a user registration and access level system... And I wonder... Is there any way to avoid to put code in every header page? Because, almost every page contains javascript, so almost every page cotains html tags... And its annoying to look at this: Warning: session_start(): Cannot send session cache limiter - headers already sent So, I'm wondering, is there any other way to avoid put code in every page? or... another way to avoid that kind of error. Thank you. _ Got a cool Hotmail story? Tell us now http://clk.atdmt.com/UKM/go/195013117/direct/01/ A key concept to remember is that HTML is inserted into your PHP code, and not the other way around. Once I realised the difference, I found I was making the header/output mistake far less often. Anyway, to answer the question, what most apps/websites do for this is to use controller code to load in the correct HTML as necessary. The first lines of most of my apps are general include lines. One for DB, one for other config, etc. That way, I can just use the include files for doing things that need to be done for every page. Common logic for a login is to use an include file that does this: 1. Is user logged in? Yes: goto 5. No: goto 2 2. Have login details been submitted through form or other? Yes: goto 3. No: goto 4 3. Are login details correct? Yes: goto 5, No: goto 4 4. Show login form stop 5. Show/redirect to app page (apologies for the hard to follow list, but I just realised I don't know a good way to show a flowchart in plain text!) Use include files for your HTML headers, and only include them after you've done everything you need to with session_start() and header() calls. If there's content that changes in the header from page to page, put that in a variable that you use in the included file. +1 Let me amplify this by suggesting that you minimize the PHP code inside your HTML. Like this: 1. Load your main PHP file. Do any calculations, etc., in it. 2. At the end of that file, load in a generic HTML template file. This file would contain everything from the html tag to the /html tag. 3. Inside your template file, make a call to a view file, which is unique for this page. It should contain all the HTML code outside the actual template. In this file, make whatever PHP code limited to echoing values and loops. The values displayed, etc., are formulated in the original PHP file. That's one way to do it. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now http://clk.atdmt.com/UKM/go/195013117/direct/01/
RE: [PHP] Help with template file and email
Let me get this right... $mymail // If you put an email adress it works, right. You are calling variable $mymail... But, what does contain that var? You are calling $mymail, there has to be a database, or something of those 10 mails you said. -If i'm getting you the point right- If not, my mistake. Or you might use something like this: ?php // mail list $to = 'yourma...@example.com' . ', '; $to .= 'yourma...@example.com'; If my answer is wrong for you. Plrease reffer to: http://docs.php.net/manual/en/function.mail.php -as Richard said.- From: rquadl...@gmail.com Date: Tue, 13 Jul 2010 15:02:14 +0100 To: j.hendrick...@comcast.net CC: php-general@lists.php.net Subject: Re: [PHP] Help with template file and email On 13 July 2010 14:56, Joey Hendricks j.hendrick...@comcast.net wrote: Hello, I have been working on a birtday invite program. The form takes 10 names and 10 email addresses. I think the problem is the $to variable in my function. I get this warning-Warning: mail() [function.mail]: SMTP server response: 550 5.5.0 f domain name required in. Could someone help me with this my email is j.hendrick...@comcast.net Thank you so very much! ?php mail(' j.hendrick...@comcast.net', 'Test email', 'This is a test email'); ? and I get the following entry in my PHP's mail.log ... mail() on [-:2]: To: j.hendrick...@comcast.net -- Headers: Pretty simple stuff. http://docs.php.net/manual/en/function.mail.php Regards, Richard. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now
[PHP] What's wrong in this function? Does not work for me.
Hello, this function does not work for me... And I really don't know what am I doing wrong... Any help?? This function is in a class, and I call it in a form, to create a new user.. $objEmploye=new Employe; if ( $objEmploye-insert(array($name,$lastname,$salary,$dui,$afp,$isss,$nit)) == true){ echo 'Saved'; }else{ echo 'Error, try again'; } }else{ function insert($field){ if($this-con-connect()==true){ return mysql_query(INSERT INTO employes (name,lastname, salary, id, afp, isss, nit) VALUES ('.$field[0].', '.$field[1].','.$field[2].','.$field[3].','.$field[4].','.$field[5].','.$field[6].')); } } Thanks. _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now
RE: [PHP] What's wrong in this function? Does not work for me.
Hello Ash, No, I don't get an error message, the thing is, my post form, isn't working... I can't post those fields in database when I fill them up in the form... But, I really don't know why... Do you want my form code? all the entire class.php code?? Thank you for helping me. Carlos Sura. Subject: Re: [PHP] What's wrong in this function? Does not work for me. From: a...@ashleysheridan.co.uk To: carlos_s...@hotmail.com CC: php-general@lists.php.net Date: Sat, 3 Jul 2010 00:08:05 +0100 On Fri, 2010-07-02 at 22:05 +, Carlos Sura wrote: Hello, this function does not work for me... And I really don't know what am I doing wrong... Any help?? This function is in a class, and I call it in a form, to create a new user.. $objEmploye=new Employe; if ( $objEmploye-insert(array($name,$lastname,$salary,$dui,$afp,$isss,$nit)) == true){ echo 'Saved'; }else{ echo 'Error, try again'; } }else{ function insert($field){ if($this-con-connect()==true){ return mysql_query(INSERT INTO employes (name,lastname, salary, id, afp, isss, nit) VALUES ('.$field[0].', '.$field[1].','.$field[2].','.$field[3].','.$field[4].','.$field[5].','.$field[6].')); } } Thanks. _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now I can't see anything wrong with that code excerpt. Are you getting a specific error, and if so, what is the code on and around the line number indicated in that error? Thanks, Ash http://www.ashleysheridan.co.uk _ http://clk.atdmt.com/UKM/go/19780/direct/01/ We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now
[PHP] Login form + User level access
Hello everyone. I have this question: I'm developing a login system but what I need is to do is access levels I mean, in my database I have this users: Admin Superusers sales purchase etc So, What I do basically need is, when a user from sales log in.. I want him to see just the menu from SALES, He cannot see others menu options, and he can't get access, I was reading that I can do that with Switch, but really I have no idea about it... Any help? Thank you. Carlos Sura. _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now
RE: [PHP] Login form + User level access
Thank you for your answer Ted, You are right, well, I do have my login form, but what I do not understand is how to implement switch statement. switch ($level){ case 0: include (admin.php); break; case 1: include (sales.php); break; case 2: include (superuser.php); break; } Now I'm wondering if every page has to have something like: if ($level==2){ } else { } but, I think that might check link pages, and whole menu... Not, just the menu for admin as example. So, that's why I'm asking for help... I was saying just the idea to get example codes, to base on it, asking : how do I get to london?, not how do I drive a car? Thanks. Carlos Sura. Date: Tue, 29 Jun 2010 15:58:10 -0400 To: carlos_s...@hotmail.com; php-general@lists.php.net From: tedd.sperl...@gmail.com Subject: Re: [PHP] Login form + User level access At 7:46 PM + 6/29/10, Carlos Sura wrote: Hello everyone. I have this question: I'm developing a login system but what I need is to do is access levels I mean, in my database I have this users: Admin Superusers sales purchase etc So, What I do basically need is, when a user from sales log in.. I want him to see just the menu from SALES, He cannot see others menu options, and he can't get access, I was reading that I can do that with Switch, but really I have no idea about it... Any help? Thank you. Carlos Sura. Carlos: That's a little like saying, I want to build a car so I can drive around the country. I was reading that I could do that with a key, but I don't have any idea about it... Any help? Yes, you can use a switch statement, but that just one control structure in a much, much larger application. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now
RE: Re[2]: [PHP] Login form + User level access
Hello Andre, Thank you so much, Now I really get the idea. Oh, can I replace that adding inthe table of access_level a field called: 'level_numbers' ?? would it be the same thing?? Carlos Sura. Date: Tue, 29 Jun 2010 23:08:51 +0300 From: an...@oire.org To: an...@oire.org CC: carlos_s...@hotmail.com; php-general@lists.php.net Subject: Re[2]: [PHP] Login form + User level access Hello Carlos, What I forgot to add is the following: I'd suggest you to put in the integers and not the strings (1 instead of PURCHASER, 2 instead of SALES etc.). It will quicken the process. -- With best regards from Ukraine, Andre Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org Yahoo! messenger: andre.polykanine; ICQ: 191749952 Twitter: m_elensule - Original message - From: Andre Polykanine an...@oire.org To: Carlos Sura carlos_s...@hotmail.com Date: Tuesday, June 29, 2010, 11:04:53 PM Subject: [PHP] Login form + User level access Hello Carlos, Something like this (assuming that the field with the type of the user - admin, sales, etc. - is called `Status`, and the table is called `Users`): $f=mysql_fetch_assoc(mysql_query(SELECT `Status`, COUNT(*) AS `UserExists` FROM `Users` WHERE `Name`='.$_POST['name'].' AND `Password`='.md5($_POST['pass']).')); if ($f['UserExists']0) { // name and password are correct switch ($f['Status']) { case 'ADMIN': include adminmenu.php; break; case 'SALES': include salesmenu.php; break; // ... } } else { die (You entered either an incorrect login or an incorrect password.); } I assume you store crypted passwords in your database, and the algorythm is md5 (there are better solutions, but I used it simply for this example). -- With best regards from Ukraine, Andre Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org Yahoo! messenger: andre.polykanine; ICQ: 191749952 Twitter: m_elensule - Original message - From: Carlos Sura carlos_s...@hotmail.com To: php-general@lists.php.net php-general@lists.php.net Date: Tuesday, June 29, 2010, 10:46:14 PM Subject: [PHP] Login form + User level access Hello everyone. I have this question: I'm developing a login system but what I need is to do is access levels I mean, in my database I have this users: Admin Superusers sales purchase etc So, What I do basically need is, when a user from sales log in.. I want him to see just the menu from SALES, He cannot see others menu options, and he can't get access, I was reading that I can do that with Switch, but really I have no idea about it... Any help? Thank you. Carlos Sura. _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now -- 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 _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now