Jump to content

rbragg

Members
  • Posts

    176
  • Joined

  • Last visited

    Never

Posts posted by rbragg

  1. Is it possible to set a form element value to an existing array? For example, I have an array called $app:

     

    <?php
    while (ocifetch($stmt1)) {
      $app = ociresult($stmt1, "FIELD"); # this is an array populated by a query results
      echo "<input type='checkbox' name='reminders[]' value='" . $app . "'>";
    }
    ?>

     

    Ultimately, I would like the values in $app to be added to the reminders[] array. Is this possible or can someone divulge a way to do this?

     

    Thanks in advance.  ;D

  2. I have a php page that creates a PDF using strings and coordinates. My problem is that I need to write a php script that will temporarily save the created PDF remotely on the server that is hosting the scripts. I already have a script that will then insert the file into my database as a blob.

     

    So, I just need something in-between that will allow me to temporarily save the file that I have created so that I can use my insertion script. I'd like for this new script to also delete the file after my insertion.

     

    Does someone know how to do this or at least can point me in the right direction so that I know what phrase to use to research in Google? ;) Thanks!

  3. Good afternoon! I am trying to retrieve a blob from my db like this:

     

    <?php
    $queryGetBlob =
    "SELECT contract_file
    FROM schema.TABLE
    WHERE contract_num = 23";
    $getBlobResult = ociparse($connect, $queryGetBlob);
    ociexecute($getBlobResult);
    
    while($arrayBlob = ocifetch($getBlobResult))
    {
    echo $arrayBlob['CONTRACT_FILE']->load();
    }
    
    ocifreestatement($getBlobResult);
    ?>

     

    I get these errors:

     

    PHP Warning:  Cannot use a scalar value as an array

     

    and

     

    PHP Fatal error:  Call to a member function on a non-object

     

    I realize that the first error is stating that $arrayBlob is not an array but I'm not sure why it isn't. This is my first time trying to fetch a blob. Can someone lend a hand? Thanks.

     

  4. <?php
    $queryInsertParent4Student = "
    INSERT into schema.STUDENT (parent_num)
    SELECT parent_num
    FROM schema.PARENT
    WHERE email = '" . $_SESSION['pMail'] . "'";
    ?>

     

    Why does the above give me this error:

     

    ORA-01400: cannot insert NULL

     

    ... when the session is tested and set AND there IS a parent_num for this email in the db?  ??? I think I'm just being dumb here. Thanks.

  5. I get the ORA-00936: missing expression error here:

     

    SELECT 
    COUNT(call_num) AS CALL, 
    COUNT(CASE WHEN status_num = 1 THEN status_num END) AS CLOSED,
    COUNT(CASE WHEN status_num = 2 THEN status_num END) AS OPEN,
    COUNT(CASE WHEN status_num = 3 THEN status_num END) AS JACK,
    COUNT(CASE WHEN status_num = 4 THEN status_num END) AS TECHFOLLOWUP,
    COUNT(CASE WHEN status_num = 5 THEN status_num END) AS RESNETFOLLOWUP,
    COUNT(CASE WHEN status_num = 6 THEN status_num END) AS HOT,
    COUNT(CASE WHEN status_num = 7 THEN status_num END) AS PROGRESS,
    COUNT(CASE WHEN status_num = 8 THEN status_num END) AS APPT,
    COUNT(CASE WHEN status_num = 9 THEN status_num END) AS STUDENT,
    COUNT(CASE WHEN status_num = 10 THEN status_num END) AS THIRD,
    FROM schema.table;

     

    Can anyone see where the problem is?? Thanks in advance!

  6. I'm getting the PHP Notice:  Undefined offset: error. I am developing a pdf and the problem arises when I wordwrap(). You have to tell the pdf to wrap because new lines are not automatically created, nor are they able to be created with (concatenated) html. The offset number will ALWAYS be the last line.

     

    Here is my script:

     

    <?php
    $display = pdf_findfont($pdf, "Courier", "host", 0); pdf_setfont($pdf, $threeC, ;
    pdf_show_xy($pdf, " ", 40, 694);
    $stringWrapped = wordwrap($string, 115, "|");
    $array = explode("|", $stringWrapped);
    $i = 0;
    while ($array[$i] != "")
    {
    pdf_continue_text($pdf, $array[$i]);
    $i++;
    }
    ?>

     

    So, if this script counts 4 lines, I will get: PHP Notice:  Undefined offset: 4. How can I keep from getting this error other than turning them off on the server? Thanks.

  7. 1) How do I incorporate so much data into a single (or a few) sessions?

     

    Each form element will need to be stored in its own session. As thorpe showed you, the POST variables should be converted to sessions. As far as checkboxes, you will need to be familiar with arrays because a checkbox group will be stored in one session.

     

    2) I also have an image uploading script which is part of form2. Do you think id have to worry about anything with that?

     

    I have no idea about this one.

     

    3) Once all the session stuff is built how do I take all the data from the session and insert everything into the db?

     

    <?php
    $query = "
    INSERT into table(field1, field2)
    VALUES ('" . $_SESSION['element1'] . "', '" . $_SESSION['element2'] . "')";
    ?>
    

     

    I'm not a mod or anything here but I hope this gets you going in the right direction.

  8. In the following query, why would RECORD_COUNT still give me a null value instead of 0 if the db was empty?

     

    <?php
    $queryContract = "
    SELECT action_num, status, NVL(COUNT(*),0) AS RECORD_COUNT
    FROM schema.HEC_ACTION 
    WHERE schema.HEC_ACTION.contract_num = '" . $_SESSION['contract'] . "'
    AND schema.HEC_ACTION.step_num = '" . $thisStep . "'
    GROUP BY action_num, status
    ORDER BY action_num, status";
    ?>

  9. Thanks for your reply. I will only have one string in $variable so I wouldn't start with an array. Also, I wouldn't need ALL of the letters from the string ... only those at the end.

    <?php
    preg_match('/(?<=\d)[a-z]+\z/i', $variable, $result);
    echo $result;
    ?>

     

    This gives me an array of letters. I would like to end up with one string from $variable. In the case of "SAN-2011Aa", I'd like to get "Aa" ... not "A" and "a". Also, I'd like to leave out "SAN".

     

    Thanks again.

  10. Is it possible to use substr() to get only the letters displayed after numbers (at the end of a string)? For example:

     

    WA-0318a would give me a

    SAN-2011Aa would give me Aa

    KE-2200Eb would give me Eb

     

    So, if $variable = "SAN-2011Aa" then substr($variable, -?). The negative length parameter would be dependent on how many of the ending characters are letters and not numbers. In this case, I would need to dynamically generate 2 (for -2). In the case of "WA-0318a" I would need to dynamically generate 1 (for -1).

     

    Is this possible?

  11. I have built a search script that searches based on what a user has entered. In this case, the user has entered a value into a textfield that is brought in with the GET method. I use that value to find the S_NUM to those matching values.

     

    Using this while loop echoes each S_NUM for each match, however, when I run the appended query, the query only uses the LAST matching S_NUM and I get one record. For example, there may be 3 S_NUM's that match the query (56, 58, 59) and the appending query only displays one record (59) when I need 3:

     

    <?php 
    # start of $querySearch here and I'm appending to it based on some criteria
    # criteria:
    if ( !empty($_GET['searchStudent']) )
    {
      $gotStudent = $_GET['searchStudent'];
    
      $queryStudentResult = "
      SELECT s_num
      FROM student
      WHERE student.s_first LIKE '%" . $gotStudent . "%' OR student.s_last LIKE '%" . $gotStudent . "%'
      ";
      $studentResult= ociparse($connect, $queryStudentResult);
      ociexecute($studentResult);
    
      while ( ocifetch($studentResult) )
      {
        $studentNum = ociresult($studentResult,"S_NUM");
        echo "<br>studentNum: " . $studentNum . "<br>";
      }
      
      $querySearch.= "AND call.s_num = " . $studentNum . " ";
    }?>

     

    I also realize I need to make some upper/lower changes with using LIKE, but first I'm just trying to get this appending functioning. How to I manipulate an array to get my desired results here? I have also tried using foreach within the While loop.

     

     

  12. Hi again, fenway!

     

    <script>
    var imgArray = new Array(4);
    imgArray[0] = new Image;
    imgArray[0].src = "images/1.gif";
    imgArray[1] = new Image;
    imgArray[1].src = "images/2.gif";
    imgArray[2] = new Image;
    imgArray[2].src = "images/3.gif";
    imgArray[3] = new Image;
    imgArray[3].src = "images/4.gif";
    var index = 0;
    
    function cycle()
    {
    document.bannerCycle.src = imgArray[index].src;
    index ++;
    if (index == 4)
    {
    	index = 0;
    }
    setTimeout("cycle()",2000);
    return;
    } 
    
    function selectRandom()
    {
    index = Math.floor(Math.random() * 4);
    document.bannerRandom.src = imgArray[index].src;
    setTimeout("selectRandom()",2000);
    return;
    }
    
    </script>
    </head>
    
    <body onLoad="cycle();selectRandom()">
    
    <center>
    <h2>My Cycling Banner</h2>
    <img name="bannerCycle" src="images/1.gif">
    
    <h2>My Random Images</h2>
    <img name="bannerRandom" src="images/1.gif">

  13. Thanks for that emehrkay! That would be great in any other case. Like I said, unfortunately, this is for a class so I can't really overhaul the structure and would have to follow the guidelines of the textbook. The script is done exactly as asked - just not functioning as asked.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.