SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi everyone:

    I can't input any information with an apostrophe (Bob's Bar) into mySQL. I am using a php3 template to input data into my database. Any advice or code I need to insert into my php page?

    <?php

    if ($submit): // A new business has been listed
    // using the form below.
    $dbcnx = @mysql_connect(
    "localhost", "XXXXXX", "XXXXXXXX");
    mysql_select_db("XXXXXX");

    $sql = "INSERT INTO Business SET " .
    "Business_Name='$businessname', " .
    "Category='$category', " .
    "Subcategory='$subcategory', " .
    "Neighborhood='$neighborhood', " .
    "Business_Description='$businessdescription', " .
    "Address_1='$address1', " .
    "Address_2='$address2', " .
    "City='$city', " .
    "State='$state', " .
    "Zipcode='$zipcode', ".
    "Phone_Number='$phonenumber', " .
    "E_Mail='$email', " .
    "Web_Site='$website', " .
    "Contact_Name='$contactname', " .
    "Date=CURDATE(),".
    "Visible='N',".
    "Expiration_Date=ADDDATE(CURDATE(), INTERVAL 6 MONTH)";

    if (mysql_query($sql)) {
    echo("<p>Thank you for adding your business listing to our directory.</P>");
    } else {
    echo("<P>Error Adding New Business Listing: " .
    mysql_error() . "</P>");
    }

    ?>

    <?php
    else: // Allow The User To Enter A New Business Listing
    ?>


  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to use addslashes() to get the apostrophes in, but you will need to revise your script a bit. for instance if the business name is "Bob's Bar" somwhere before your sql statement you will need to do $name = addslashes($name);
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •