Page 1 of 1

Xaamp on windows server

PostPosted: 27. March 2013 17:17
by xjmf
Hi..
I can access Mysql database and table using php script... but I cannot insert data into the table ....
Code: Select all
<?php
/*



{ // Connect and Test MySQL and specific DB (return $dbSuccess = T/F) 

//    Execute code ONLY if connections were successful    
if ($dbSuccess) {
   
      
      $company_SQLinsert = "INSERT INTO tCompany ( ";
      // $company_SQLinsert .=  "ID, ";
      $company_SQLinsert .=  "preName, ";
      $company_SQLinsert .=  "Name, ";
      $company_SQLinsert .=  "RegType, ";
      $company_SQLinsert .=  "StreetA, ";
      $company_SQLinsert .=  "StreetB, ";
      $company_SQLinsert .=  "StreetC, ";
      $company_SQLinsert .=  "Town, ";
      $company_SQLinsert .=  "County, ";
      $company_SQLinsert .=  "Postcode, ";
      $company_SQLinsert .=  "COUNTRY ";
      $company_SQLinsert .=  ") ";
      
      $company_SQLinsert .=  "VALUES ";
      
      { // insert Pie Company
         $company_SQLinsert .=  "(";
         //$company_SQLinsert .=  "'<autoincremented ID value>', ";
         $company_SQLinsert .=  "'The', ";
         $company_SQLinsert .=  "'Pie Company', ";
         $company_SQLinsert .=  "'', ";
         $company_SQLinsert .=  "'89 Gravy Road', ";
         $company_SQLinsert .=  "'', ";
         $company_SQLinsert .=  "'', ";
         $company_SQLinsert .=  "'Pastryville', ";
         $company_SQLinsert .=  "'NSW', ";
         $company_SQLinsert .=  "'1297', ";
         $company_SQLinsert .=  "'Australia' ";
         $company_SQLinsert .=  "), ";
      }

      { // insert TMIT       
         $company_SQLinsert .=  "(";
         //$company_SQLinsert .=  "'<autoincremented ID value>', ";
         $company_SQLinsert .=  "'', ";
         $company_SQLinsert .=  "'TMIT World', ";
         $company_SQLinsert .=  "'Limited', ";
         $company_SQLinsert .=  "'42 Lily Close', ";
         $company_SQLinsert .=  "'', ";
         $company_SQLinsert .=  "'', ";
         $company_SQLinsert .=  "'Bicester', ";
         $company_SQLinsert .=  "'Oxfordshire', ";
         $company_SQLinsert .=  "'OX26 3EJ', ";
         $company_SQLinsert .=  "'UK' ";
         $company_SQLinsert .=  "), ";
      }

      { // insert JACASTA       
         $company_SQLinsert .=  "(";
         //$company_SQLinsert .=  "'<autoincremented ID value>', ";
         $company_SQLinsert .=  "'', ";
         $company_SQLinsert .=  "'JACASTA', ";
         $company_SQLinsert .=  "'Limited', ";
         $company_SQLinsert .=  "'42 Lily Close', ";
         $company_SQLinsert .=  "'', ";
         $company_SQLinsert .=  "'', ";
         $company_SQLinsert .=  "'Bicester', ";
         $company_SQLinsert .=  "'Oxfordshire', ";
         $company_SQLinsert .=  "'OX26 3EJ', ";
         $company_SQLinsert .=  "'UK' ";
         $company_SQLinsert .=  ") ";
      }
      
      
      if (mysql_query($company_SQLinsert))  {   
         echo "INSERT INTO tCompany - SUCCESSFUL.<br /><br />";
      } else {
         echo "INSERT INTO tCompany - FAILED.<br /><br />";
      }




I get INSERT INTO tCompany - FAILED.... and no other error..
Thanks John

[edit by Altrea: added code-BBCode tags around php code]

Re: Xaamp on windows server

PostPosted: 27. March 2013 17:57
by Altrea
Hi John,

xjmf wrote:I get INSERT INTO tCompany - FAILED.... and no other error..

Well, if you don't use the mysql_error() function, you will not get any helpful error messages.
Another good idea would be to echo out the full sql Statement.

best wishes,
Altrea

Re: Xaamp on windows server

PostPosted: 28. March 2013 15:01
by xjmf
Thanks for your reply... but any help on why the database will not insert the data into the fields..

Re: Xaamp on windows server

PostPosted: 28. March 2013 16:17
by Altrea
xjmf wrote:Thanks for your reply... but any help on why the database will not insert the data into the fields..

How should i know why the database will not insert the data?
The only information i have is the pre-processed code which should build the sql query.

It is a script issue. It is YOUR script. Start debugging! I have told your which the next steps would be.

If you would really want that we do the debugging for you (which is not the support area of this board here), you have to give us everything which is needed to rebuild a test environment. That includes the Database Schema in sql Syntax, the Database Connection user with permission information, the full script, full information about the server configuration (Apache, MySQL and PHP), information about how the script will get executed (Request and Response), etc. Maybe (!!) then someone here will be willing to do the debugging work for you.

best wishes,
Altrea