[Help]Need help with variables php,Sql

I have a table users contain fiedls "old,new & total"
when submit , update users SET total = $total
where $total = $old+$new
I did this , I used echo to make sure it is ok , but it is not :
/* Variable to Count Total  */
$old=$row_rs_users['old'];
$new=$row_rs_users['new'];
$total=$old+ $new;
echo $total;
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "doit_form")) {
  $updateSQL = sprintf("UPDATE users SET total=%s WHERE id=%s",
                       $total,
                       GetSQLValueString($_POST['id'], "int"));
Thanks,

Seeing only part of your code, it's impossible to debug.
However, your approach is wrong anyway. All you need to do is to add the new value to the old one in the SQL query.
$updateSQL = sprintf("UPDATE users SET total=(total+%s) WHERE id=%s",
                       GetSQLValueString($_POST['fieldName'], "double"),
                       GetSQLValueString($_POST['id'], "int"));
$_POST['fieldName'] is the new value being added. Use "double" if the value contains a decimal point. If it's an integer, change "double" to "int".

Similar Messages

  • I need help with DW, PHP & MySQL please.

    Hello, I am new to website development and am trying to set up a form for collecting data on my website and have a question that I can’t find an answer to anywhere else. I was wandering if someone there would be kind enough to help?  I am using Dreamweaver in CS4 and my host already has PHP & MySQL installed on the server that I can use.  My question is: Do I need to download XAMP or WAMP on my computer before trying to connect my form to the server?  Also, do I need to change the page I am putting the form on to .PHP extension or can I just embed the PHP form into an existing HTML page?
    Most of the training tutorials I’ve read don’t start at the most basic beginning but rather expect people to already have a basic knowledge of the topics they are trying to learn.  If anyone knows the best place to get answers to the most basic questions like this one or a beginners guide to working with DW, PHP & MySQL I will gladly go there rather than waste your time on questions you’ve probably already answered a bezillion times.
    Thank you for the help.

    Strictly speaking, you don't need XAMPP or WAMP on your local computer. But if you're serious about getting involved with PHP/MySQL, you should definitely set up a local testing environment with one or the other. It's safer and more efficient. Don't expose all your errors on a live server. You can find instructions on  how to set up a testing environment here: http://www.adobe.com/devnet/dreamweaver/articles/setting_up_php.html.
    To develop with PHP, you should always use a .php file name extension. Any other choice is very rare.
    There's a tutorial on building your first dynamic website with DW here: http://www.adobe.com/devnet/dreamweaver/articles/first_dynamic_site_pt1.html.
    For more in-depth help, you might want to consider grabbing hold of a copy of "The Essential Guide to Dreamweaver CS4 with CSS, Ajax, and PHP". (Yes, I wrote it, so it's a bit of shameless self-promotion, but you'll find it answers many of your questions - and probably a lot you hadn't even thought of.)

  • Need help with simple php files

    I have simple php files that are setup with includes for a header, sidebar and footer... all other data is within the file. There is no dynamic info on the pages, yet I cannot get the files to load up in InContext. Is there a way to make this work?
    I can get an html file to work flawless, but something seems to stop the php file from working.
    Thanks,
    Ken Henderson

    What I mean is, whenever I try to edit any file with a php extension, I get a 404 error... even a simple file with no includes. I created a php file with one line of text within an editable region and I still could not edit it with InContext.
    The site I'm trying to work with is http://www.thunderbirdchemical.com
    The homepage is index.php
    The simple test file I made is test.php
    Thanks for your help.
    Ken

  • Help with anonymus pl/sql layout using javascript

    Hi people.
    i want to display some records on a region (using apex 4.2) , this anonymous pl/sql script below shows 3 records from database, but the layout only shows me the first record with it's data, the others 2 records, only show me labels.
    i have verified this same query creating a report and it shows the 3 records correctly.
    i guess i am doing something wrong with this javascript routine or i am surely missing something,
    in this link you can see the layout i am getting. (http://sdrv.ms/Xrv0J8).
    the other little help i need is to display in one row for each record. actually i am getting one row for each label and one row for each data record. i have read and found is something about /div, but i don't no how to change it to get desired results, any suggestion is welcome.
    thanks in advance for any help.
    i am completely new in apex and java script, but i have several years experience in pl/sql.
    The Script :
    Begin
    Declare
    Cursor Deliv Is
    Select item,
    To_char (Delivery, 'month dd, yyyy hh24:mi:ss') Delivery,
    Current_date
    From pending_items;
    Begin
    For A In Deliv Loop
    Begin
    Sys.Htp.P ('<script type="text/javascript">');
    Sys.Htp.P ('function cdtd() {');
    Sys.Htp.P (' var xmas = new Date("' || a.delivery || '")');
    Sys.Htp.P (' var now = new Date();');
    Sys.Htp.P (' var timeDiff = xmas.getTime() - now.getTime();');
    Sys.Htp.P (' if (timeDiff <= 0) {');
    Sys.Htp.P (' clearTimeout(timer);');
    -- Sys.Htp.P (' document.write("Some Text Here!");');
    Sys.Htp.P (' // Run any code needed for countdown completion here');
    Sys.Htp.P (' }');
    Sys.Htp.P (' var seconds = Math.floor(timeDiff / 1000);');
    Sys.Htp.P (' var minutes = Math.floor(seconds / 60);');
    Sys.Htp.P (' var hours = Math.floor(minutes / 60);');
    Sys.Htp.P (' var days = Math.floor(hours / 24);');
    Sys.Htp.P (' hours %= 24;');
    Sys.Htp.P (' minutes %= 60;');
    Sys.Htp.P (' seconds %= 60;');
    Sys.Htp.P (' document.getElementById("daysBox").innerHTML = days;');
    Sys.Htp.P (' document.getElementById("hoursBox").innerHTML = hours;');
    Sys.Htp.P (' document.getElementById("minsBox").innerHTML = minutes;');
    Sys.Htp.P (' document.getElementById("secsBox").innerHTML = seconds;');
    Sys.Htp.P (' var timer = setTimeout("cdtd()",1000);');
    Sys.Htp.P ('}');
    Sys.Htp.P ('</script>');
    Sys.Htp.P ('Days ');
    Sys.Htp.P ('<div id="daysBox"></div>');
    Sys.Htp.P ('Hours');
    Sys.Htp.P ('<div id="hoursBox"></div>');
    Sys.Htp.P ('Minutes');
    Sys.Htp.P ('<div id="minsBox"></div>');
    Sys.Htp.P ('Seconds');
    Sys.Htp.P ('<div id="secsBox"></div>');
    Sys.Htp.P ('<script type="text/javascript">');
    Sys.Htp.P ('cdtd();</script>');
    End;
    End Loop;
    End;
    End;

    Let's focus on your delivery dates and javascript for now.
    Why you would put your javascript in htp.p calls in a plsql region is quite beyond me. When you edit the page there is a javascript region where you can put global variables and functions, an excellent spot for this then, and a lot more maintainable than this.
    Now it's also obvious that your query on pending items will return more than one record. So, using a report would serve you well in this case. However, using code like this:
    document.getElementById("daysBox").innerHTML = days;
    document.getElementById("hoursBox").innerHTML = hours;
    document.getElementById("minsBox").innerHTML = minutes;
    document.getElementById("secsBox").innerHTML = seconds;will not serve you. getElementById is meant to return one element uniquely identified by an ID. If you have a report with multiple rows, and elements on each row with the same ID, you are doing something wrong. You would need the delivery date per row, and I guess that you put out your code with htp.p because you do not know how to deal with that and passing it in to the javascript procedure.
    But wouldn't it be more oppurtune for you to simply create a report with a source sql where you calculate each part of the date, and then refresh this region with a certain interval. If you'd refresh every 5 minutes, wouldn't that be more than fast enough to keep track of things? Don't forget, refreshing a region will execute the sql again.
    It's not that you can't accomplish a multirecord report with a countdown per row, but are you comfortable enough with javascript and jquery to code and maintain that versus leveraging plsql and dynamic actions (there is even a dynamic action timer plugin provided by oracle)?

  • Help with some PL/SQL Triggers

    hello there, I'm totally new using PL/SQL so I need your help with two triggers.
    For instance
    1. Compare two dates, and verify that there are different, you must send a message Error
    2. When I insert a new record, a trigger must obtain data from other tables and add it (on a new record)
    Maybe not the answers, maybe the way to go!
    Thks!

    Hi,
    Welcome to the forum
    1. Compare two dates, and verify that there are different, you must send a message Errorwhy trigger ?
    Trigger is Only for when DML Performed :)
    try 1st one in procedure..
    create or replace procedure testing(p_date in date)
    is
    v_date date;
    begin
    select to_date(hiredate,'mm-dd-rr') into v_date
    from emp
    where to_date(hiredate,'mm-dd-rr')=to_date(p_date,'mm-dd-rr');
    dbms_output.put_line(v_date);
    exception
    when others then
    dbms_output.put_line('No Data Found');
    end;
    2. When I insert a new record, a trigger must obtain data from other tables and add it (on a new record)i didn't understand can you please explain me in detail ?
    Thanks
    Venkadesh

  • Please help with workflow inspired SQL

    Hi everyone, I need some help with a piece of sql I need to create. It will be used in a workflow scenario and is therefore a bit hairy and has some limitations. So here goes..
    I have 2 current tables that will be used in this query. The first is a table used as a supervisor cross reference, and the second will be used for signing authority, or approval authorization. In short...the first table will give you the supervisor for the particular employee or employee in the where clause. This tells us who to route to. The second table has the operators authority level. As an example.... 1, 2, 3, or 4. A 1 could signify that this supervisor can approve for up to $5,000, and a 4 could signify that this person can approve up to $250,000. thats the basic idea.
    So what I need to do in ONE statement is get the requestor's supervisor, and then check his/hers authority level for level 1, 2, 3 or 4. The authority level needed will be passed into the query, so I will have that as well as the requestor. And here is the hard part...... If no rows are returned (the supervisor does not have authority to approve) I need the query to apply the same logic to the next supervisor. In other words, the supervisor's supervisor. Every requestor will have a supervisor. Every supervisor will also have a supervisor....so it goes until we get to the CEO. So the query needs to keep going until it finds a row matching the signing authority.
    So the limitations are......this needs to happen in one SQL query, and this query can only return ONE field!
    Here are some creates and inserts to give you something to work with. Been suffering with this one for a few days so your help is GREATLY appreciated.
    Supervisor cross reference table
    CREATE TABLE PS_ROLEXLATOPR (ROLEUSER VARCHAR2(30) DEFAULT ' ' NOT
    NULL,
    DESCR VARCHAR2(30) DEFAULT ' ' NOT NULL,
    OPRID VARCHAR2(30) DEFAULT ' ' NOT NULL,
    EMAILID VARCHAR2(70) DEFAULT ' ' NOT NULL,
    FORMID VARCHAR2(70) DEFAULT ' ' NOT NULL,
    WORKLIST_USER_SW VARCHAR2(1) DEFAULT 'Y' NOT NULL,
    EMAIL_USER_SW VARCHAR2(1) DEFAULT 'Y' NOT NULL,
    FORMS_USER_SW VARCHAR2(1) DEFAULT 'Y' NOT NULL,
    EMPLID VARCHAR2(11) DEFAULT ' ' NOT NULL,
    ROLEUSER_ALT VARCHAR2(30) DEFAULT ' ' NOT NULL,
    ROLEUSER_SUPR VARCHAR2(30) DEFAULT ' ' NOT NULL,
    EFFDT_FROM DATE,
    EFFDT_TO DATE) TABLESPACE PTTBL STORAGE (INITIAL 40000 NEXT 100000
    MAXEXTENTS UNLIMITED PCTINCREASE 0) PCTFREE 10 PCTUSED 80
    INSERT INTO PS_ROLEXLATOPR
    DESCR,
    OPRID ,
    EMAILID ,
    FORMID ,
    WORKLIST_USER_SW ,
    EMAIL_USER_SW ,
    FORMS_USER_SW ,
    EMPLID ,
    ROLEUSER_ALT ,
    ROLEUSER_SUPR ,
    EFFDT_FROM
    VALUES
    DESCR,
    'ABC123',
    'XYZ123',
    Signing Authority table..
    CREATE TABLE PS_ZZ_WF_AUTHORITY (OPRID VARCHAR2(30) NOT NULL,
    EMPLID VARCHAR2(11) NOT NULL,
    EMAILID VARCHAR2(70) NOT NULL,
    ZZ_SIGN_AUTHORITY VARCHAR2(1) NOT NULL) TABLESPACE APLARGE STORAGE
    (INITIAL 40000 NEXT 100000 MAXEXTENTS UNLIMITED PCTINCREASE 0)
    PCTFREE 10 PCTUSED 80
    insert into PS_ZZ_WF_AUTHORITY
    OPRID,
    EMPLID,
    EMAILID,
    ZZ_SIGN_AUTHORITY
    Values
    'XYZ123',
    'Any_Email',
    '1'
    )

    Hi,
    Welcome to the forum!
    Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful!
    Whenever you have a question, also post the results you want to get from the sample data your posted.
    Always say what version of Oracle you're suing.
    In the sample data you posted, I only see one row in each table. Does that really give a good picture of the problem? If the problem involves going up the chain of command 1, 2, 3 or more levels, then shouldn't you have a chain of at least 3 people to show the problem and test the results?
    I think what you need is CONNECT BY Query , which works on a table with a parent-child relationship. Given a parent, you can find that ow's children, the children's children, their children, and so on, however many generations there are.
    I don't think I can demonstrate this with your sample data, so I'll use the scott.emp table, whcih you should be able to query.
    The emp table contains a hierarcy of employees, including this data:
    NAME                 EMPNO        MGR        SAL JOB
    KING                  7839                  5000 PRESIDENT
       JONES              7566       7839       2975 MANAGER
          SCOTT           7788       7566       3000 ANALYST
             ADAMS        7876       7788       1100 CLERK
          FORD            7902       7566       3000 ANALYST
             SMITH        7369       7902        800 CLERK
       BLAKE              7698       7839       2850 MANAGER
          ALLEN           7499       7698       1600 SALESMAN
          WARD            7521       7698       1250 SALESMAN
          MARTIN          7654       7698       1250 SALESMAN
          TURNER          7844       7698       1500 SALESMAN
          JAMES           7900       7698        950 CLERK
       CLARK              7782       7839       2450 MANAGER
          MILLER          7934       7782       1300 CLERKThis show, among other things, that the employee with ename='KING' (empno=7839) has no boss.
    JONES (empno=7566) does have a boss (mgr=7839), namely KING.
    SCOTT (empno=7788) has a bos (mgr=7566), who is JONES.
    I got the results above using this CONNECT BY query:
    SELECT     LPAD ( ' '
              , 3 * (LEVEL - 1)
              ) || ename          AS name
    ,     empno
    ,     mgr
    ,     sal
    ,     job
    FROM     scott.emp
    START WITH     mgr     IS NULL
    CONNECT BY     mgr     = PRIOR empno
    ;This is an example of a Top-Down Query , where we start with a parent, then find its children, grandchildren, and so on.
    In your probelm, you want to do a Bottom-Up Query ; given a child, you want to see if its parent has a certain level of authority. If not, you need to look at that parent's parent, and keep going until to either reach someone with the right qualifications, or you reach the end of the chain of command.
    That's similar to this problem: given a set of employees in scott.emp (say, everyone with job='CLERK') we want to find their closest ancestor who has a sal of 3000 or more. Look at the data above: you can see that SMITH is a CLERK, and SMITH'S boss, FORD, has sal=3000, so we want a row of output that shows SMITH and FORD.
    For a different example, looks at MILLER. MILLER's boss, CLARK, only has sal=2450, so we need to look at CLARK's boss, KING.
    One way to do that in a CONNECT BY query is:
    SELECT     CONNECT_BY_ROOT ename     AS subordinate
    ,     ename
    ,     LEVEL - 1          AS steps_apart
    FROM     scott.emp
    WHERE     CONNECT_BY_ISLEAF     = 1
    START WITH     job       = 'CLERK'
    CONNECT BY     empno       = PRIOR mgr
         AND     PRIOR sal < 3000
    ;Output:
    SUBORDINAT ENAME      STEPS_APART
    SMITH      FORD                 1
    ADAMS      SCOTT                1
    JAMES      KING                 2
    MILLER     KING                 2You should be all set to write the query now.
    Just kidding. I'll bet there's a lot of stuff in this message that's new to you. It's all documented in the SQL Language manual:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/index.htm
    If you'd like help, post your version, a more complete set of sample data, and the results you want from that data.
    Explain, with specific examples, how you get the results you posted from the data you posted.
    Do as much of the query as you can, and post your code.

  • Help with html / php contact form

    Hi guys I was hoping to get some help with a contact form on my website, to be honest I havent a clue about php but kind of okay with html thats why the php code is just a copy and paste from some website, just trying to marry it up with the html but getting errors.
    Hopfully one of you can see the problem.
    Error on Submitting:
    Notice: Undefined variable: name in \\nas44ent\Domains\g\gethinhayman.co.uk\user\htdocs\send_form_email.php on line 69
    Notice: Undefined variable: message in \\nas44ent\Domains\g\gethinhayman.co.uk\user\htdocs\send_form_email.php on line 75
    We are very sorry, but there were error(s) found with the form you submitted. These errors appear below.
    The Name you entered does not appear to be valid.
    The Comments you entered do not appear to be valid.
    HTML Code:
    <section id="contact" class="four">
                                                                <div class="container">
                                                                          <header>
                                                                                    <h2>Contact</h2>
                                                                          </header>
                                                                          <form method="post" action="send_form_email.php">
                                                                                    <div class="row half">
                                                                                              <div class="6u"><input type="text" class="text" name="name" placeholder="Name" /></div>
                                                                                              <div class="6u"><input type="text" class="text" name="email" placeholder="Email" /></div>
                                                                                    </div>
                                                                                    <div class="row half">
                                                                                              <div class="12u">
                                                                                                        <textarea name="message" placeholder="Message"></textarea>
                                                                                              </div>
                                                                                    </div>
                                                                                    <div class="row">
                                                                                              <div class="12u">
                                                                                                        <a href="http://www.mywebsite.co.uk/email_form.php" class="button submit">Send Message</a>
                                                                                              </div>
                                                                                    </div>
                                                                          </form>
                                                                </div>
                                                      </section>
    php Code:
    <?php
    if(isset($_POST['email'])) {
        $email_to = "my email address";
        $email_subject = "Mail from Site";
        function died($error) {
            // your error code can go here
            echo "We are very sorry, but there were error(s) found with the form you submitted. ";
            echo "These errors appear below.<br /><br />";
            echo $error."<br /><br />";
            echo "Please go back and fix these errors.<br /><br />";
            die();
        // validation expected data exists
        if(!isset($_POST['name']) ||
            !isset($_POST['email']) ||
            !isset($_POST['message'])) {
            died('We are sorry, but there appears to be a problem with the form you submitted.');      
        $first_name = $_POST['name']; // required
        $email_from = $_POST['email']; // required
        $comments = $_POST['message']; // required
        $error_message = "";
        $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
      if(!preg_match($email_exp,$email_from)) {
        $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
        $string_exp = "/^[A-Za-z .'-]+$/";
      if(!preg_match($string_exp,$name)) {
        $error_message .= 'The Name you entered does not appear to be valid.<br />';
      if(strlen($message) < 1) {
        $error_message .= 'The Comments you entered do not appear to be valid.<br />';
      if(strlen($error_message) > 0) {
        died($error_message);
        $email_message = "Form details below.\n\n";
        function clean_string($string) {
          $bad = array("content-type","bcc:","to:","cc:","href");
          return str_replace($bad,"",$string);
        $email_message .= "Name: ".clean_string($name)."\n";;
        $email_message .= "Email: ".clean_string($email)."\n";
        $email_message .= "Message: ".clean_string($message)."\n";
    // create email headers
    $headers = 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
    @mail($email_to, $email_subject, $email_message, $headers); 
    ?>
    <?php
    ?>

    PHP CODE:  SaveAs send_form_email.php
    <?php
    if(isset($_POST['email'])) {
        // EDIT THE 2 LINES BELOW AS REQUIRED
        $email_to = "[email protected]";
        $email_subject = "Your email subject line";
        function died($error) {
            // your error code can go here
            echo "We are very sorry, but there were error(s) found with the form you submitted. ";
            echo "These errors appear below.<br /><br />";
            echo $error."<br /><br />";
            echo "Please go back and fix these errors.<br /><br />";
            die();
        // validation expected data exists
        if(!isset($_POST['name']) ||
            !isset($_POST['email']) ||
            !isset($_POST['message'])) {
            died('We are sorry, but there appears to be a problem with the form you submitted.');     
        $name = $_POST['name']; // required
        $email_from = $_POST['email']; // required
        $comments = $_POST['message']; // required
        $error_message = "";
        $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
      if(!preg_match($email_exp,$email_from)) {
        $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
        $string_exp = "/^[A-Za-z .'-]+$/";
      if(!preg_match($string_exp,$name)) {
        $error_message .= 'The Name you entered does not appear to be valid.<br />';
      if(strlen($message) < 2) {
        $error_message .= 'The message you entered does not appear to be valid.<br />';
      if(strlen($error_message) > 0) {
        died($error_message);
        $email_message = "Form details below.\n\n";
        function clean_string($string) {
          $bad = array("content-type","bcc:","to:","cc:","href");
          return str_replace($bad,"",$string);
        $email_message .= "Name: ".clean_string($name)."\n";
        $email_message .= "Email: ".clean_string($email_from)."\n";
        $email_message .= "Message: ".clean_string($message)."\n";
    // create email headers
    $headers = 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
    @mail($email_to, $email_subject, $email_message, $headers);
    ?>
    <!-- include your own success html here -->
    Thank you for contacting us. We will be in touch with you very soon.
    <?php
    ?>
    HTML Code -- save as html page.
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Contact Form</title>
    </head>
    <body>
    <section id="contact" class="four">
    <div class="container">
    <header>
    <h2>Contact</h2>
    </header>
    <form method="post" action="send_form_email.php">
    <div class="row half"> <div class="6u">
    <input type="text" class="text" name="name" placeholder="Name" />
    </div>
    <div class="6u">
    <input type="text" class="text" name="email" placeholder="Email" />
    </div>
    </div>
    <div class="row half"> <div class="12u">
    <textarea name="message" placeholder="Message"></textarea>
    </div>
    </div>
    <div class="row">
    <div class="12u">
    <input type="submit" name="submit" value="Send">
    </div>
    </div>
    </form>
    </div>
    </section>
    </body>
    </html>
    Upload both to your Apache server to test.
    EDIT:  changed typo on Submit button -- valuse to value.
    Nancy O.

  • Help With Some PHP

    On
    www.imagesandwords.org.uk/andrewjamesrp/
    I had a go with a PHP CSS switcher using a tutorial from,
    www.alistapart.com/articles/phpswitch/
    and I can't seem to get it working.
    I want to do some more complex changes in the css but for now am just trying to work out the php. Can anyone help me? I am not sure what information to inclue but I have done my damndest to follow the tutorial.
    You can see that the page isn't in the root directory but the php and css files are in the andrewjamesrp folder.
    Thanks
    Martin

    Thanks Nate
    Here's the link: http://imagesandwords.org.uk/andrewjamesrp/index.html
    Here's switcher.php
    < ?php
    $set = $_GET['set'];
    setcookie ('sitestyle', $set, time()+31536000, '/', 'www.imagesandwords.org.uk', '0');
    header("Location: $HTTP_REFERER");
    ?>
    Here's my < head>:
    < link href="stylemain.css" rel="stylesheet" type="text/css" media="all"/>
    < link rel="stylesheet" type="text/css" media="screen" title="User Defined Style" href="<?php echo (!$sitestyle)?'stylemain':$sitestyle ?>.css" />
    < link rel="alternate stylesheet" type="text/css" media="screen" title="Red" href="red.css" />
    < link rel="alternate stylesheet" type="text/css" media="screen" title="Blue" href="blue.css" />
    < link rel="alternate stylesheet" type="text/css" media="screen" title="Green" href="green.css" />
    < /head>
    And here's the switch in the < body>
    < li id="red">< a href="./switcher.php?set=styleone">1</a></li>
    < li id="green">< a href="/switcher.php?set=styletwo">2</a></li>
    < li id="blue">< a href="switcher.php?set=stylethree">3</a></li>
    I have used different ways of referencing the switcher.php there because I am not sure how to do it. This page is a practice in my own site so the index.html is not in the true root.
    I have changed the file extension to .html and I think my host uses PHP 4.2.something. Or not PHP 5.
    Regards
    Martin

  • Help with newsletter PHP Mail script for mySQL / cron job

    I'm just trying to set up a PHP script to send emails as a cron job.
    It pretty much seems to work, but I can't get it to do two parts.
    The first part is to send the emails, and the second is to send a notification email to the site owner confirming that the emails have been sent.
    The script looks like:
    <?php
    include_once "connect_to_mysql.php";
    $sql = mysql_query("SELECT UserID, Firstname, Email, Newsletter_Received FROM Users WHERE Firstname='test' LIMIT 20");
    $numRows = mysql_num_rows($sql);
    $mail_body = '';
    while($row = mysql_fetch_array($sql)){
      $id = $row["UserID"];
      $email = $row["Email"];
      $name = $row["Firstname"];
      $mail_body = 'Test - please ignore';
        $subject = "Safari Awards Newsletter";
        $headers  = "From:[email protected]\r\n";
        $headers .= "Content-type: text/html\r\n";
        $to = "$email";
        $mail_result = mail($to, $subject, $mail_body, $headers);
      if ($mail_result) {
      mysql_query("UPDATE Users SET Newsletter_Received='1' WHERE Email='$email' LIMIT 20");
      } else {
    ?>
    <?php
    if ($numRows == 0) {
      $subj = "Newsletter Sent";
      $body = "The current newsletter has been sent to everyone.";
         $hdr  = "From:[email protected]\r\n";
         $hdr .= "Content-type: text/html\r\n";
         mail("[email protected]", $subj, $body, $hdr);
    ?>
    Basically with the line
    include_once "connect_to_mysql.php";
    included, it sends the emails as per the SELECT query, but does not send the 'Newsletter Sent' email.
    But if I take out that line, it obviously doesn't send the emails as per the SELECT query, but it does send the 'Newsletter Sent' email.
    Any suggestions on what might need changing in order for it to do both would be much appreciated!
    Thanks.

    Change this line -
    if ($numRows == 0) {
    to this -
    if ($mail_result) {

  • Help with Flex - PHP - and SQL Server

    Good afternoon,
    I have been working on this problem for over a week and am at
    my wit's end. I am trying to create an application that will allow
    me and my fellow statisticians to share code easily. The
    technologies at my disposal are Flex, PHP and SQL Server 2005. The
    web server is IIS. I have downloaded and installed the PHP driver
    for SQL Server 2005 and am able to query the database and generate
    XML. The problem I'm having is that I can't return the XML from PHP
    to Flex.
    If I execute the php code in a web browser and view the
    source, it looks like XML. I can then cut and paste the exact same
    code into an xml file and read it in from the harddisk and the tree
    will populate. Can anyone please help me? I don't have flex builder
    so I it's hard for me to use trace and view what is going on.
    Thanks in advance,
    Eric Graves

    Thanks for the suggestion. I have tried every permutation of
    e4x path notation I can think of. You're right, you're not supposed
    to need the root level as that's supposed to be returned in the
    result. So you should only need to reference first level after the
    root. When I do this and launch the .SWF I get a completely empty
    tree.
    I think the problem lies somewhere in my understanding of
    what format Flex needs returned from a HTTPRequest. It's my
    understanding that it just needs to be XML. As far as I can tell,
    that's what I'm sending it. On the PHP side, does it have to be
    cast a special way? Everything I've seen just shows people using
    ECHO to output the XML data.

  • Need Help with Formula using SQL maybe

    I need help!  I work with Crystal reports XI and usually manage just fine with the Formula editor but his one I think will require some SQL and I am not good at that.
    We are running SQL 2000 I think (Enterprise Manager 8.0)  Our sales people schedule activities and enter notes for customer accounts.  Each is stored in a separate table.  I need to find activities that are scheduled 240 days into the future and show the most recent note that goes with the account for which that activity is scheduled.
    The two tables, Activities and History, share the an accountID field in common that links them to the correct customer account.   I want to look at dates in the Startdate.Activities field more than 240 days in the future and show the most recent note from the History table where the accountid's match. I figure my query will contain a join on AccountID.Activities and AccountID.History used with Max(completedate.History) but I do not understand how to word it.
    I would like to perform all this in crystal if possible.  I humbly request your help.
    Membery

    You SQL would look something like this...
    SELECT
    a.AccountID,
    a.BlahBlahBlah, -- Any other fields you want from the Activities table
    h.LastComment
    FROM Activities AS a
    LEFT OUTER JOIN History AS h ON a.AccountID = h.AccountID
    WHERE (a.ActivityDate BETWEEN GetDate() AND DateAdd(dd, 240, GetDate()))
    AND h.HistoryID IN (
         SELECT MAX(HistoryID)
         FROM History
         GROUP BY AccountID)
    This method assumes that the History table has a HistoryID that increments up automatically each time a new comment is added... So a comment made today would always have a higher HistoryID that one made yesterday.
    If I'm wrong and there is no HistoryID or the HistoryID doesn't increment in a chronological fashion, it can still be done but the code is a bit more complex.
    HTH,
    Jason

  • Need help with Muse PHP (JavaScript error...email)

    Hey all....
    I searched and did not see an answer for this:
    I am exporting my Muse file to HTML and keep getting this error for my Contact Us page (email issue):
    "JavaScript Error:Form PHP Script is missing from web server, or PHP is not configured correctly or your web host provider.  Check if the form PHP script as been uploaded correctly, then contact your hosting provider about PHP configuration."
    What PHP version does MUSE support....5.1?  I contacted HostGator and they just updated my PHP to 5.5 and asked me what PHP MUSE needs. HostGator says 5.1 is old and they do not support 5.1. Can anyone help me?
    Also, when I try to check PHP with: http://my-site.com/scripts/form_check.php I just get an "oops" screen, but does not verify my PHP.????
    Thanks

    Difficult to debug without the URL for the form page on your site...
    Are you using the built-in File > Upload to FTP Host in Muse? Or did you use File > Export as HTML and uploaded with some other tool?
    Does http://<insert your domain name here>/scripts/museutils.js load anything? Or does it also give an "oops" screen? If it gives an "oops" screen, that would imply not all the exported files were uploaded to your server, they weren't uploaded to the correct location, or the permissions aren't set correctly.
    For forms Muse only requires PHP 4.1 or later. PHP version is not the issue.

  • Need help with min max sql

    hi all, forgot i had a user name and password and haven't needed help for quite a bit since i didn't do sql for a while but now i'm back at reporting again...
    Here is a sample table as i remember it:
    Item     Date     Time     Time Frame     Duration     Duration Frame
    A     20100926     0     5     500     10
    A     20100926     600     10     500     30
    A     20100926     1500     12     100     30
    B     20100926     1800     28     200     40
    B     20100926     2200     6     150     70
    B     20100926     2600     15     600     60
    B     20100926     3600     30     200     70
    Results Set (expected):                         
    Item     Date     Time     Total Duration          
    A     20100926     0     1600:20     --basically max (time+duration) - min(time+duration)     
    B     20100926     1800     2000:00
    Sorry, but. I didnt put my sql statement as I wasn't planning on posting and left it at work, but, i've been looking on internet and people say to use min/max function and i've attenpted it with it works with just this table (without grouping). But as soon as i group it the values seem to mess up.
    Last i remembered it gave me:
    Item     Date     Time     Total Duration          
    A     20100926     0     1600:30     --basically max(time+duration) - min(time+duration)     
    B     20100926     1800     2000:70
    I think it's looking at max duration which is 30&70 and hence it retrurns those values in the result set. Is it because of the max function hence it's returning this value? any help is appreciated. thanks
    Edited by: stanleyho on Sep 30, 2010 4:44 PM

    Okay, here we go again, repost, hopefully okay this time:
    Hi Madhu, okay, just got to work: I am using TOAD and working in Oracle 10g. Here is my table structure and the query i use to try and get what I am looking for:
    There is one extra table but that is only used to link these two tables listed below so i didn't bother posting it.
    TABLE: TX_RECON_INSTANCE_VIEW
    ColumnName ColID DataType Null
    CHANNEL_CODE 3 VARCHAR2 (4 Char) N
    DURATION 8 NUMBER (10) N
    DURATION_FRAME 9 NUMBER (2) N
    REAL_TIME 6 NUMBER (10) N
    REAL_TIME_FRAME 7 NUMBER (2) N
    ITEM_ID 4 NUMBER Y
    TX_DATE 2 CHAR (8 Byte) N
    TX_ID 1 NUMBER (9) N
    TX_TYPE 13 VARCHAR2 (4 Char) N
    TABLE: TX_SCHEDULE
    ColumnName ColID PK Null DataType
    TX_TYPE 22 N VARCHAR2 (4 Char)
    TX_ID 1 1 N NUMBER (9)
    TX_DATE 2 N CHAR (8 Byte)
    SCHEDULE_TIME_FRAME 9 N NUMBER (2)
    SCHEDULE_TIME 8 N NUMBER (10)
    REAL_TIME 10 N NUMBER (10)
    DURATION_FRAME 13 N NUMBER (2)
    DURATION 12 N NUMBER (10)________________________________________
    And the data and results:
    TX_ID TX_DATE REAL_TIME REAL_TIME_FRAME DURATION DURATION_FRAME ITEM_ID AS RUN TIME AS RUN DURATION SCHEDULED TIME SCHEDULED DURATION SCHEDULE_TIME SCHEDULE_TIME_FRAME DURATION_1 DURATION_FRAME_1
    1651000 20100710 0 0 545 20 1234 00:00:00:00 00:09:05:20 00:00:00:00 00:09:05:20 0 0 545 20
    1752223 20100710 667 12 281 7 1234 00:11:07:12 00:04:41:07 00:11:07:10 00:04:41:07 667 10 281 7
    1846501 20100710 1071 13 335 9 1234 00:17:51:13 00:05:35:09 00:17:50:09 00:05:35:09 1070 9 335 9
    2001102 20100710 1525 6 249 14 1234 00:25:25:06 00:04:09:14 00:25:22:08 00:04:09:14 1522 8 249 14
    3246669 20100710 1800 0 586 2 1235 00:30:00:00 00:09:46:02 00:30:00:00 00:09:46:02 1800 0 586 2
    4456822 20100710 2492 16 276 5 1235 00:41:32:16 00:04:36:05 00:41:32:16 00:04:36:05 2492 16 276 5
    1253168 20100710 2890 15 222 17 1235 00:48:10:15 00:03:42:17 00:48:10:15 00:03:42:17 2890 15 222 17
    1112456 20100710 3277 18 297 0 1235 00:54:37:18 00:04:57:00 00:54:35:10 00:04:57:00 3275 10 297 0
    Grouped results set:
    TX_DATE ITEM_ID AS RUN TIME AS RUN DURATION SCHEDULED TIME SCHEDULED DURATION
    20100710 1234 00:00:00:00 00:29:34:20 00:00:00:00 00:29:31:20
    20100710 1235 00:30:00:00 00:29:34:17 00:30:00:00 00:29:32:17
    --> SCHEDULED DURATION "00:29:31:20" is not correct as it should be (00:25:22:08+00:04:09:14)-(00:00:00:00)=00:29:31:22
    --> see expected results below
    Expected results:
    TX_DATE ITEM_ID AS RUN TIME AS RUN DURATION SCHEDULED TIME SCHEDULED DURATION
    20100710 1234 00:00:00:00 00:29:34:20 00:00:00:00 00:29:31:22
    20100710 1235 00:30:00:00 00:29:34:18 00:30:00:00 00:29:34:10________________________________________
    And the query I am using:
    SELECT --TXR.TX_ID,
    TXR.TX_DATE, TXR.ITEM_ID,
    TO_CHAR(TRUNC((MIN(TXR.REAL_TIME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) )/3600),'FM00')||':'||TO_CHAR(TRUNC(MOD(MIN(TXR.REAL_TIME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) ,3600)/60),'FM00')||':'||TO_CHAR(MOD(MIN(TXR.REAL_TIME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) ,60),'FM00')||':'||TO_CHAR(MOD(MIN(TXR.REAL_TIME_FRAME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) ,60),'FM00') "AS RUN TIME",
    to_char(trunc((MAX(TXR.REAL_TIME+TXR.DURATION)-MIN(TXR.REAL_TIME))/3600),'FM00')||':'||to_char(trunc(mod(MAX(TXR.REAL_TIME+TXR.DURATION)-MIN(TXR.REAL_TIME),3600)/60),'FM00')||':'||to_char(mod(MAX(TXR.REAL_TIME+TXR.DURATION)-MIN(TXR.REAL_TIME),60),'FM00')||':'||to_char(mod(MAX(TXR.REAL_TIME_FRAME+TXR.DURATION_FRAME)-MIN(TXR.REAL_TIME),60),'FM00') "AS RUN DURATION",
    TO_CHAR(TRUNC((MIN(TXS.SCHEDULE_TIME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) )/3600),'FM00')||':'||TO_CHAR(TRUNC(MOD(MIN(TXS.SCHEDULE_TIME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) ,3600)/60),'FM00')||':'||TO_CHAR(MOD(MIN(TXS.SCHEDULE_TIME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) ,60),'FM00')||':'||TO_CHAR(MOD(MIN(TXS.SCHEDULE_TIME_FRAME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) ,60),'FM00') "SCHEDULED TIME",
    to_char(trunc((MAX(TXS.SCHEDULE_TIME+TXS.DURATION)-MIN(TXS.SCHEDULE_TIME))/3600),'FM00')||':'||to_char(trunc(mod(MAX(TXS.SCHEDULE_TIME+TXS.DURATION)-MIN(TXS.SCHEDULE_TIME),3600)/60),'FM00')||':'||to_char(mod(MAX(TXS.SCHEDULE_TIME+TXS.DURATION)-MIN(TXS.SCHEDULE_TIME),60),'FM00')||':'||to_char(mod(MAX(TXS.DURATION_FRAME),60),'FM00') "SCHEDULED DURATION"
    FROM TX_RECON_INSTANCE_VIEW TXR, TX_SCHEDULE TXS, TX_SCHEDULE_RECON TXREC
    WHERE TXR.TX_DATE=20100926 AND TXR.TX_TYPE='P'
    AND TXR.TX_ID=TXREC.RECON_TX_ID(+)
    AND TXREC.BASE_TX_ID=TXS.TX_ID(+)
    GROUP BY TXR.TX_DATE, TXR.ITEM_ID
    ORDER BY TXR.TX_DATE, TXR.ITEM_ID, MAX(TXR.REAL_TIME)--does this work for everyone now? let me know...thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need Help With Basics of SQL

    Hey I'm trying to get a working understanding of some of the basics behind SQL, I've composed a few questions that I think may help me with this. Anyone that can help me with any of them will greatly help me thanks.
    1. How to create synonym for tables?
    2. How to describe the structure of tables?
    3. How to list the contents of tables?
    4. How to create a table named with the same structure as another table?
    5. How to copy rows with less than a certain criteria in value (e.g. Price<$5.00) into another table?
    6. How to change the data type to e.g. NUMBER(6)?
    7. How to add a new column named with data type e.g. VARCHAR2(10)?
    8. How to change a specific field within a table (e.g. For ORDER_NUMBER 12489, change the C_NUMBER to 315)?
    9. How to delete a specific row from a table?
    10. How to declare a column as the primary key of a table and call it e.g. PK_something?
    11. How to show certain columns when another column is less than a certain criteria in value (e.g. Price<$5.00)?
    12. How to show certain columns with another column having a certain item class e.g. HW or AP?
    13. How to list certain columns when another column e.g. price is between two values?
    14. How to list certain columns when another column e.g. price is negative?
    15. How to use the IN operator to find certain columns (e.g. first and last name of customers who are serviced by a certain ID)
    16. How to find certain columns when one of the columns begins with a particular letter (e.g. A)
    18. How to list the contents of the a table sorted in ascending order of item class and, within each item class, sorted in descending order of e.g. price?
    19. How to do a count of column in a table?
    20. How to sum a column and make rename is something?
    21. How to do a count of a column in a table (without repeats e.g. if a certain number repeats more than once than to only count it once)?
    22. How to use a subquery to find certain fields in columns when the another column’s fields values are greater than e.g. its average price?

    848290 wrote:
    Hey I'm trying to get a working understanding of some of the basics behind SQL, I've composed a few questions that I think may help me with this. Anyone that can help me with any of them will greatly help me thanks.To use the terminology you have in those questions, you must already have a basic understanding of SQL, so you have exposed yourself as not being the author of such questions.
    Please do not ask homework questions without having at least attempted to answer them yourself first and show where you're struggling.

  • Need Help with Creating the SQl query

    Hi,
    SQL query gurus...
    INFORMATION:
    I have two table, CURRENT and PREVIOUS.(Table Defs below).
    CURRENT:
    Column1 - CURR_PARENT
    Column2 - CURR_CHILD
    Column3 - CURR_CHILD_ATTRIBUTE 1
    Column4 - CURR_CHILD_ATTRIBUTE 2
    Column5 - CURR_CHILD_ATTRIBUTE 3
    PREVIOUS:
    Column1 - PREV_PARENT
    Column2 - PREV_CHILD
    Column3 - PREV_CHILD_ATTRIBUTE 1
    Column4 - PREV_CHILD_ATTRIBUTE 2
    Column5 - PREV_CHILD_ATTRIBUTE 3
    PROBLEM STATEMENT
    Here the columns 3 to 5 are the attributes of the Child. Lets assume that I have two loads, One Today which goes to the CURRENT table and one yesterday which goes to the PREVIOUS table. Between these two loads there is a CHANGE in the value for Columns either 3/4/5 or all of them(doesnt matter if one or all).
    I want to determine what properties for the child have changed with the help of a MOST efficient SQL query.(PARENT+CHILD is unique key). The Database is ofcourse ORACLE.
    Please help.
    Regards,
    Parag

    Hi,
    The last message was not posted by the same user_name that started the thread.
    Please don't do that: it's confusing.
    Earlier replies give you the information you want, with one row of output (maximum) per row in current_tbl. There may be 1, 2 or 3 changes on a row.
    You just have to unpivot that data to get one row for every change, like this:
    WITH     single_row  AS
         SELECT     c.curr_parent
         ,     c.curr_child
         ,     c.curr_child_attribute1
         ,     c.curr_child_attribute2
         ,     c.curr_child_attribute3
         ,     DECODE (c.curr_child_attribute1, p.prev_child_attribute1, 0, 1) AS diff1
         ,     DECODE (c.curr_child_attribute2, p.prev_child_attribute2, 0, 2) AS diff2
         ,     DECODE (c.curr_child_attribute3, p.prev_child_attribute3, 0, 3) AS diff3
         FROM     current_tbl    c
         JOIN     previous_tbl   p     ON  c.curr_parent     = p.prev_parent
                                AND c.curr_child     = p.prev_child
         WHERE     c.curr_child_attribute1     != p.prev_child_attribute1
         OR     c.curr_child_attribute2     != p.prev_child_attribute2
         OR     c.curr_child_attribute3     != p.prev_child_attribute3
    ,     cntr     AS
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= 3
    SELECT     s.curr_parent     AS parent
    ,     s.curr_child     AS child
    ,     CASE     c.n
              WHEN  1  THEN  s.curr_child_attribute1
              WHEN  2  THEN  s.curr_child_attribute2
              WHEN  3  THEN  s.curr_child_attribute3
         END          AS attribute
    ,     c.n          AS attribute_value
    FROM     single_row     s
    JOIN     cntr          c     ON     c.n IN ( s.diff1
                                    , s.diff2
                                    , s.diff3
    ORDER BY  attribute_value
    ,            parent
    ,            child
    ;

Maybe you are looking for