Jump to content
Larry Ullman's Book Forums

dickm

Members
  • Posts

    29
  • Joined

  • Last visited

Posts posted by dickm

  1. I have the following query which when pasted into phpmyadmin sql works and returns results

     

    SELECT h.rec_id AS CapLog, h.remoteid AS Reference, h.branch AS Branch, h.dtplnprtd AS PrelimDate, h.estimate AS Estimate, h.cname AS Company, h.mycustomer AS OurCustomer, CONCAT_WS( ' ', RTRIM( h.jobsite1 ) , RTRIM( h.jobsite2 ) , RTRIM( h.jobsite3 ) , RTRIM( h.jobsite4 ) , RTRIM( h.jobsite5 ) , RTRIM( h.jobsite6 ) , RTRIM( h.jobsite7 ) ) AS Jobsite, h.contractor AS Contractor

    FROM history h

    INNER JOIN customer c

    USING ( cusid )

    WHERE c.username = 'USERCPO'

    AND h.dtplnprtd

    BETWEEN '20110524' and '20110622'

    ORDER BY mycustomer

    ====================================================================================================================

    Now the same query but using the variables instead of the static data in RED above returns no results in my script file???

     

    $query = "SELECT h.rec_id AS CapLog, h.remoteid AS Reference, h.branch AS Branch, h.dtplnprtd AS PrelimDate, h.estimate AS Estimate, h.cname AS Company, h.mycustomer AS OurCustomer, CONCAT_WS( ' ', RTRIM( h.jobsite1 ) , RTRIM( h.jobsite2 ) , RTRIM( h.jobsite3 ) , RTRIM( h.jobsite4 ) , RTRIM( h.jobsite5 ) , RTRIM( h.jobsite6 ) , RTRIM( h.jobsite7 ) ) AS Jobsite, h.contractor AS Contractor

    FROM history h

    INNER JOIN customer c

    USING ( cusid )

    WHERE c.username = '$remcode' and h.dtplnprtd BETWEEN '$dbegin' and '$dend'

    ORDER BY mycustomer";

     

    Any ideas as to what is wrong would be appreciated.

  2. Sorry for taking so long to respond. I created the following sample script to show how JS should be separated from the HTML:

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    
    <html lang="en">
    
     <head>
    
       <title>onsubmit test</title>
    
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
     </head>
    
     <body>
    
       <form action="http://en.wikipedia.org/wiki/Wiki" method="post">
    
         <p><label for="firstname">First name: </label><input type="text" name="firstname" id="firstname"></p>
    
         <p><input type="submit" value="Submit"></p>
    
       </form>
    
       <script type="text/javascript">
    
         document.forms[0].onsubmit = function() {
    
           window.open(this.action,'','width=1000,height=700,left=500,top=5')
    
           return false;
    
         };
    
       </script>
    
     </body>
    
    </html>

     

    Also, if you do use the inline defintion, which I do not recommend, then you shouldn't use return false. You need to return a JS function/method. Please Google this for more info. I'm not going to explain it here though, because you shouldn't be using inline definitions anyway.

     

    Also, the first argument for window.open is the URL, and URLs cannot contain relative paths (i.e., ./ and ../).

     

    As a more minor point, the default for scrollbars and resizeable is yes, so you don't need to specify those. Also, top is only supported in IE, so you need to consider that.

     

    Lastly, if you don't want to use forms[0] in the JS, you can assign a name to the form and use that. For example:

     

    <form action="http://en.wikipedia.org/wiki/Wiki" method="post" name="homer">
    
    ...
    
    document.homer.onsubmit = function() {

     

    That help?

  3. I have changed this non-working code around from the previous that was submitted above. Now a new window is being opened, but errors with "Internet Explorer cannot display the webpage" The correct URL is showing in the browser address bar.

     

    <form action="./form/AZCondFinRel.php" onsubmit="window.open(this.action,'popupwin','width=1000,height=700,left=500,top=5,scrollbars=yes,resizable=yes');return false;" method="post" >

    If I remove the onsubmit command and attributes, the form opens correctly but in existing window.

     

    So still puzzled.

  4. Having a problem with opening an addition window. This next coding portion is working correctly and opening the href in a new window.

     

    <td><a href="form_selection.php" onClick="window.open(this.href, 'popupwindow2','width=1100,height=800,left=500, top=50, scrollbars=yes,resizable=yes');return false;"><h4> Select and Prepare New Legal Form </h4> </a></td>

     

    ===============================================================================

     

    Now this segment of coding from a form is not working. The form action is opening the correct php page, but it is not opened in a new window as desired. Can anyone see what is wrong as it is basically the same as the href process. I have changed dimensions, I have changed "this.form.action" to many different variations with spaces, quotes, brackets, etc, but the page is ran correctly, just not in a new window.

     

    <form method="post" action="/form/AZCondFinRel.php" onSubmit="window.open( this.form.action,'popupwin','width=1000,height=700,left=50,top=5,scrollbars=yes,resizable=yes');return false;" >

     

    Mahalo

  5. For debugging, try printing out your query variable and any MySQL errors that may be happening:

     

    echo "<p>Query: $query</p><p>MySQL Error: " . mysql_error() . "</p>";

    Place that under your other echo statements and see if your query has the variables you expect, and whether MySQL is producing errors. You won't see database errors unless you use PHP's functions to display them.

     

    Thanks Paul;

     

    Printing out the results helped me track down my problems which were multiple. Two of the variables were not updating correctly from the previous POST and two were just my stupid misspelling.

     

    Now have the process working correctly.

     

    Mahalo

  6. This is driving me crazy. The echo statements for testing are returning the correct where condition variables but the columns are not updated in the table

     

     

    $query = ("UPDATE forms SET form_date = NOW(), form_amount = $camt, form_dispamt = $damt WHERE form_cusid = '$cusid' AND form_recid = '$rec_id' AND TRIM(form_type) LIKE '$afrmtype'");

    $result = mysql_query ($query); // Run the query.

     

    echo ' Form ID: '. ' [<b>' .$frmid. ' </b> ]'; // this is the correct record id which is an auto-increment value

    echo ' Number of Rows: '. ' [<b>' .$num_rows. ' </b> ]'; // this is returning a count of 1 record

     

    Any help would be greatly appreciated. I have tried it with '$camt' for the SET variables and have tried the ".$camt." also and nothing has changed. The all give the same echo results but not update of data.

     

    Mahalo

  7. Okay, I have modified my code based on Larry's process on page 550, but am getting the error:

    //Warning: mysql_fetch_array() expects parameter 2 to be long, string given in C:\xampp\htdocs\preview_setup_AZ_state_form.php on line 343. Line 343 is the while condition line.

     

    I can't rely on post I don't think, because my user editing option occurs a few screens later, when they have an option to make changes based on a new display of information so that is why is am using SESSION instead of POST. Any suggestions for corrections would be appreciated.

     

    <p><b>Signee to use for this form: </b> </p><br />

    <?php

     

    require_once ('./php/mysql_connect.php'); // Connect to the db.

    $cusid=$_SESSION['cusid'];

    $query="SELECT relcusid, concat(authsign,'-',signtitle) as mysig FROM relsignor

    WHERE relcusid=$cusid";

     

    $result = mysql_query ($query);

     

    if (mysql_num_rows($result) > 0) {

    while($row=mysql_fetch_array($result, mysql_num )) {

    echo '<option value=\"$row[0]\"';

    if ($_SESSION['my_sig'] == $row) {echo 'selected="selected"';

    echo ">$row[1]</option>\n";

    }

    }

    }

    Mahalo

  8. Larry, after rereading and then studying your Sticky form process in PHP6 and MYSQL 5 Visual Quickpro Guide, I made the following corrections to my code and the radio button process is now working correctly for me.

     

    I first eliminated all the variable creation at the start and eliminated all the if else conditions that were working with the new variables that I created and just used what was already stored session variables from the original form.

     

    <p><b>Joint Check You Selected to:</b>

     

     

    <p> <input type="radio" name="jtchkname" <?PHP if ($_SESSION['jt_cknam']== 'none') {echo 'checked="checked"';} ?>/>None</p>

    <p> <input type="radio" name="jtchkname" <?PHP if ($_SESSION['jt_cknam']== 'mycustomer') {echo 'checked="checked"';} ?>/>My Customer</p>

    <p> <input type="radio" name="jtchkname" <?PHP if ($_SESSION['jt_cknam']== 'contractor') {echo 'checked="checked"';} ?>/>Contractor</p>

    <p> <input type="radio" name="jtchkname" <?PHP if ($_SESSION['jt_cknam']== 'lender') {echo 'checked="checked"';} ?>/>Lender</p>

    <p> <input type="radio" name="jtchkname" <?PHP if ($_SESSION['jt_cknam']== 'owner') {echo 'checked="checked"';} ?>/>Owner</p>

    <p> <input type="radio" name="jtchkname" <?PHP if ($_SESSION['jt_cknam']== 'other') {echo 'checked="checked"';} ?>/>Other Name</p>

     

    <P>

     

    I just have to learn to read more intelligently and follow your great examples, but thought I would pass this on to maybe help others.

    Mahalo

  9. Here is the code that I have and on the first page that it appears, it allows the user to select only one of the options. However, when I return the full form for further editing by the user of all form items, this second of code always returns the checked option of 'owner'. The default option on the first page is 'none' and even if left at that, on the review page is is 'owner'. Any suggestions would be great.

     

    ==========First page code=======

    <p><b>Joint Check to Who:</b>

    <p> <input type="radio" name="jtchkname" value="none" checked="checked"/>None</p>

    <p> <input type="radio" name="jtchkname" value="mycustomer"/>My Customer</p>

    <p> <input type="radio" name="jtchkname" value="contractor" />Contractor</p>

    <p> <input type="radio" name="jtchkname" value="lender"/>Lender</p>

    <p> <input type="radio" name="jtchkname" value="owner"/>Owner</p>

    <p> <input type="radio" name="jtchkname" value="other" />Other Name</p>

    </p>

    ==========Review page code=======

     

    <?PHP

    $none_status = "unchecked";

    $mycustomer_status = "unchecked";

    $contractor_status = "unchecked";

    $lender_status = "unchecked";

    $owner_status = "unchecked";

    // session jt_cknam is created from the post of jntchkname from first page

    if ($_SESSION['jt_cknam'] == 'none') {

    $none_status = "checked";

    }

    else if ($_SESSION['jt_cknam'] == 'mycustomer') {

    $mycustomer_status = "checked";

    }

    else if ($_SESSION['jt_cknam'] == 'contractor') {

    $contractor_status = "checked";

    }

    else if ($_SESSION['jt_cknam'] == 'lender') {

    $lender_status = "checked";

    }

    else if ($_SESSION['jt_cknam'] == 'owner') {

    $owner_status = "checked";

    }

    //}

     

    ?>

     

    <p><b>Joint Check to Who:</b>

    <p> <input type="radio" name="jtchkname" value="none" checked = '$none_status'/>None</p>

    <p> <input type="radio" name="jtchkname" value="mycustomer" checked = '$mycustomer_status' />My Customer</p>

    <p> <input type="radio" name="jtchkname" value="contractor" checked='$contractor_status'/>Contractor</p>

    <p> <input type="radio" name="jtchkname" value="lender" checked = '$lender_status '/>Lender</p>

    <p> <input type="radio" name="jtchkname" value="owner" checked = '$owner_status'/>Owner</p>

     

    <P>

    Mahalo

  10. I am having trouble trying to control the amount of data that a user can enter in a textarea on a form.

     

    The code (just a small segment of the full page form that I have is as follows:

     

    <hr />

    <p><b>Special Notes Regarding this form information: </b></p>

    <p><textarea cols="45" rows="5" name="comments" wrap="hard"> </textarea></p>

    <br />

    <hr />

     

    I have the limit set at 5 rows, but when typing in the area, the user can continue on and on and this will be unacceptable. I have thought of a message to say only type on the first 5 lines, but that doesn't seem to be very professional.

     

    Any help would be appreciated

     

    Mahalo,

  11. The below code generates a pull down menu list of names that user can select to use. It is one of many input options on the form including text and radio button form options. I am able to store all the other input options to be redisplayed in case of editing needs, but unable to redisplay the user selection from this signature pull down menu. When I return the user to this page currently the signature pull down menu is at the default start display, not the users choice.

     

    Any suggestions would be appreciated.

     

    <?php

     

    require_once ('./php/mysql_connect.php'); // Connect to the db.

    $cusid=$_SESSION['cusid'];

    $query="SELECT relcusid, concat(authsign,'-',signtitle) as mysig FROM relsignor

    WHERE relcusid=$cusid";

    $result = mysql_query ($query);

    echo "<select name = mysig value=''>mysig</option>";

     

    while($nt=mysql_fetch_array($result)){//Array of records stored in $nt

    echo '<option value=" ' . $nt["mysig"]. ' "> '. $nt["mysig"] .'</option>';

    }

    echo "</select>";

    ?>

    <p><b>Signature to use: </b> </p><br />

    <hr />

     

    <div align="center"><input type="submit"

    name="submit" value="Submit My Information" />

    <input type="hidden" name="submitted" value="TRUE" />

    </div>

  12. Okay Larry, I have changed the code as follows and it still is not opening an additional window.

     

    <table align="center" cellspacing="0" cellpadding="5">

    <tr>

    <td><a href="form_selection.php" onclick="window.open(this.href, \'popupwindow2\',\'width=600,height=400,left=30, top=10, scrollbars=yes,resizable=yes\');return false;"> Select and Prepare New Legal Form </a></td>

    </tr>

    </table>

     

    Mahalo,

  13. Okay Larry, I have changed the code as follows which includes some height and width changes just for visual testing and it is not opening an additional window.

     

    <table align="center" cellspacing="0" cellpadding="5">

    <tr>

    <td><a href="form_selection.php" onclick=window.open(this.href, \'popupwindow2\',\'width=600,height=400,left=30, top=10, scrollbars=yes,resizable=yes\');return false;"> Select and Prepare New Legal Form </a></td>

    </tr>

    </table>

     

    Mahalo,

  14. Sorry for the confusion Larry, so I must not be explaining myself properly. The initial display of data is a grouping of records and fields of information in rows. Each row of the ten row display has the rec_id at the left and it is underlined with the href tag. When the user selects one of the records the in the top code, a second window is opened with the sizes in the code that is smaller than the initial display of the records , and in this window is display all the fields of information related to that record. What I want to do with the second set of coding is all the user to again click on an href tag that will display some additional information in a third window but smaller than the second window.

     

    This way they can close the smallest (third window) and still be able to access information from the second window before also closing that window and returning to the original display of ten records.

     

    Hope this helps.

     

    dickm

  15. Aloha to everyone.

     

    I am trying to give some editing options to users and am trying to work with opening additional windows and having some problems. The first additional window is opened with the following code and is working correctly.

     

    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

    $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color.

    echo '<tr bgcolor="' . $bg . '">

    <td align="left"><a href="view_full_record_form.php?rec_id=' . $row['rec_id'] . '" onclick="window.open(this.href, \'popupwindow\',\'width=1000,height=800,left=200, top=50, scrollbars=yes,resizable=yes\');return false;">' . $row['rec_id'] . '</a></td>

     

    Now I am trying to open another, smaller popup window inside of the existing window and am using the following code, but it is not opening another window and I can't see my problem.

     

    <table align="center" cellspacing="0" cellpadding="5">

    <tr>

    <td><a href="form_selection.php" "onclick=window.open(this.href, \'popupwindow2\',\'width=800,height=600,left=30, top=10, scrollbars=yes,resizable=yes\');return false;"> Select and Prepare New Legal Form </a></td>

    </tr>

    </table>

     

    Thank you for any help that you can provide.

     

    Mahalo

     

    dickm

    PHP 5.3.1

    MYSQL 5.1.41

  16. Just thought that I would pass along the solution to this error problem.

     

    In my coding I had the following new code additions:

     

    $cust = escape_data($_REQUEST['customer']);

    $_SESSION['mycustomer']=$cust;

     

    What became the indication solution for me was the part of the error statement that said

    "be advised that the session extension does not consider global variables as a source of data",

    so I changed the code as follows and the error condition did not appear:

     

     

    $_SESSION['mycustomer'] = escape_data($_REQUEST['customer']);

     

    Hope this helps clarify this problem for others also.

     

    dickm

  17. I am now getting this error in my coding, since adding the last module that we have been discussing regarding single and double quotes in the previous topic:

     

    Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0

     

    I have been looking thru my code and not finding any variables with the same name as the session variable. Any other causes??

     

    dickm

×
×
  • Create New...