Jump to content

Eiolon

Members
  • Posts

    358
  • Joined

  • Last visited

Posts posted by Eiolon

  1. I am using PHP with ODBC to connect to an existing MSSQL database to query for some names.  When I query a name that has an apostrophe in it, I get an error.

     

    Example typing O'Malley as the name:

     

    Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver]

    Incorrect syntax near 'malley'., SQL state 37000 in SQLExecDirect
    [/quote]

    I have used addslashes to the string but get the same result:

    [code]
    $string = addslashes($_POST['string']);

    $connect = odbc_connect("$mssql_name", "$mssql_user", "$mssql_pass");

    $query_mssql = "SELECT pr.NameFirst, pr.NameLast, pr.NameMiddle, pr.Birthdate, p.Barcode, p.OrganizationID
    FROM PatronRegistration pr
    JOIN Patrons p ON (pr.PatronID = p.PatronID)
    WHERE pr.NameLast = '$string'";

    $result = odbc_exec($connect, $query_mssql);
    [/code]

     

    Any ideas?

  2. PHP does not know that $address is a web address.  You need to make sure you are putting either http:// in front of cnn.com for $address, or you need to add http:// in the link.

     

    So either this:

     

    $address = "http://www.cnn.com";
    
    <a href="<?php echo $address ?>">Go To</a>
    

     

    or

     

    $address = "cnn.com";
    
    <a href="http://<?php echo $address ?>">Go To</a>
    

  3. Already did that.  I can make this work with tables, I just know it's not proper to use tables for design elements.

     

    I can make it work with absolute positioning, but it only shows properly in IE and not Firefox/Chrome.

  4. The database needs a way to know if a time is clocked in / clocked out so it knows which times to subtract.

     

    If you have an employee that has clocked in and out 6 times in one day, how would it know which two to subtract?

     

    If an employee clocks in 2 times, but only clocked out 1 time, it needs to know not to subtract the last time clocked in because there has been no clock out yet.

  5. If you are trying to connect to an external database, permissions must be set on that database to allow access.  For example, with MySQL, you could need to grant access:

     

    GRANT ALL PRIVILEGES ON db_name.* TO username@'IP_ADDRESS_HERE' IDENTIFIED BY 'password_here';
    

     

    Then you create a new database connection using the above information.

     

    EDIT: Forgot to mention if they are not using the default MySQL port you will need to define that as well.

  6. I have a top and bottom image, each in their own DIV.  However, there is white space that I cannot get rid of that is preventing the images from looking seamless.

     

    Here is a screenshot of the image:

     

    spacing.gif

     

    The images are in the HEADER and MIDDLE divs.

     

    #wrapper {
    margin:0px auto;
    padding:0;
    border:0;
    width: 1024px;
    }
    
    #header {
    margin:0;
    }
    
    #container {
    margin:0;
    padding:0;
    }
    
    #left {
    margin:0;
    padding:0;
    float:left;
    width:255px;
    }
    
    #right {
    margin:0;
    padding:0;
    float:right;
    width:255px;
    }
    
    #middle { 
    margin:0;
    padding:0;
    float:left;
    width:514px;
    }
    

     

    <div id="wrapper">
    <div id="header">
    	<img src="header.jpg" alt="Header">
    </div>
    <div id="container">
    	<div id="left">
    
    	</div>
    
    	<div id="middle">
    		<img src="middle.jpg" alt="Middle">
    	</div>
    
    	<div id="right">
    
    	</div>
    </div>
    </div>

  7. My script forces all names to start with a capital and lower case for the rest.  However, some names have a ' or - in them.

     

    For example:

     

    Rosie O'Donnell

     

    or

     

    Carrie-Anne Moss

     

    With the script, the "D" in O'Donnell is lower case and the "A" in Anne is lower case.

     

    What do I need to do to make them capital?

     

    Here is what I am using:

     

    <?php echo ucwords(strtolower($row_persons['last_name'])) ?>, <?php echo ucwords(strtolower($row_persons['first_name'])) ?>

  8. I am trying to insert the record when the link is clicked.  This way I already have the auto incremented ID.  I have to submit a couple of forms, but they are both on the same page.  If I had the record ID already generated, I can redirect back to the form ID when the first form is submitted.

  9. I currently have a table where the name is one column for both the first and last name.

     

    Names are entered in the following format:

     

    Smith, John

     

    I would like to have a column for both first and last name.  What would be the best method to splitting the names up so the first and last name ends up in the respective columns?

     

    I am trying not to have to retype everything as there are about 300 names.

  10. I assume when you mean PHP only you are not involving a database...

     

    So if that is the case, have each radio button assigned a value.  When submitted, get the value.  In your PHP, tell it something like:

     

    
    $value = $_GET['submittedvalue'];
    
    if ($value == 1) {
       echo "<img src=image/image1.jpg>";
    } elseif  {
    ($value == 2) {
       echo "<img src=image/image2.jpg>";
    }
    

     

    Just repeat until you've used all your images.  Of course, make sure it is secure and if you are using a database you can make it more elegant.

  11. To make things simple, many people will create an admin area to do all the major administration tasks.  One each page, when checking for the session, also check to see if the user has admin status.

     

    It would be unwise to allow regular users to see admin tools and functions, only to have them be denied access when executing the script.  Just deny them access altogether by not letting them see the admin features in the first place.

  12. If I put this in a new HTML document:

     

    <?php
    
    $number = 1234.56;
    
    // let's print the international format for the en_US locale
    setlocale(LC_MONETARY, 'en_US');
    echo money_format('%i', $number) . "\n";
    // USD 1,234.56
    
    ?>

     

    as per the PHP manual, I get:

     

    Fatal error: Call to undefined function money_format() in C:\wamp\www\accounts\test.php on line 7

     

    Line 7 is:  echo money_format('%i', $number) . "\n";

     

     

    I have tried setting different locales and same result.  Any ideas on what I need to do to get it to work?

  13. I am trying to make it so two definiton lists are side by side instead of on top of each other.  I'm not sure what to do to put them side by side.  Thanks for your help!

     

    current.gif

     

    wanting.gif

     

    My CSS:

     

    #summary {
    background:#FAFAFA;
    border: 1px solid #E8E8E8;
    padding:15px 10px 10px 15px;
    font-family:Arial, Helvetica, sans-serif;
    font-size:13px;
    color: #000000;
    }
    
    #summary  dl {
    clear: both;
    }
    
    #summary dt {
        float: left;
        clear: left;
    width: 130px;
        text-align: left;
      }
    
    #summary  dd {
        margin: 0 0 0 0;
        padding: 0 0 0.7em 0;
    color:#000000;
    }
    

     

    and HTML

     

    <div id="summary">
    <dl>
    <dt>Account</dt> <dd>SMALL TOOLS AND EQUIPMENT</dd>
    <dt>Code</dt> <dd>503-523</dd>
    <dt>Fiscal Year</dt> <dd>2010-2011</dd>
    </dl>
    <dl>
    <dt>Budget Amount</dt> <dd>$10000.00</dd>
    <dt>Amount Spent</dt> <dd>$5000.00</dd>
    <dt>Amount Remaining</dt> <dd>$5000.00</dd>
    </dl>
    </div>

×
×
  • 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.