Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

?
Lv 4

Php Insert not working ?

Hi

My php insert script is not working, it used to work, now it does not seem to.

here's my code

<?php

include('connect.php');

//sanitize input

$compname=(strip_tags($_POST['compname']));

$compdesc=(strip_tags($_POST['compdesc']));

$compslog=(strip_tags($_POST['compslog']));

$sql=("INSERT INTO `a4264749_company`.`company` (`company_name`, `company_description`, `company_slogan`, `cash`, `staff`, `warehouses`, `machines`) VALUES ('$compname','$compdesc','$compslog','10000000,50,1,10)");

Nothing's being inserted, not even the text.

Here's the code in pastebin http://pastebin.com/rZJWgJ1n

Thanks.

3 Answers

Relevance
  • 9 years ago
    Favorite Answer

    First, I'd write the SQL query straight in SQL, i like to use MYSQL query browser. Once you get the sql correct, then I take the php variables and instead of trying to inserting them into the sql echo them out to make sure they are being passed correctly. Once you know they are being passed then try to insert the variables into your query.

  • 9 years ago

    From the PasteBin code, I suspect it could be due to an error by unnecessary usage of Single Quote ( ' ) before " '10000000 "

    Integers don't need a Single Quote unless its a String. Trial to see if to omit this Single Quote or to Add another Single Quote after the value, as needed.

    And an excerpt from Best Practices of Programming - always try to capture the errors thrown, for easy debugging. Here you could use MySQL's Die() function.

    -- In 'thoughts'...

    Lonely Rogue.

  • 9 years ago

    use this when you do the insert

    die(mysql_error())

    you may have a sql error...and you don't see it

Still have questions? Get your answers by asking now.