CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Jul 2005
    Posts
    141

    insert query failed.. only when online

    hi...

    i've a php code which works perfectly when it's on my localhost apache server... but when i uploaded it onto my server on the internet.. it gives an error... here's the partial code:

    Code:
    <?PHP
    
    $name = addslashes($_POST['name']);
    $crimeType = addslashes($_POST['crimeType']);
    $crimeDesc = addslashes($_POST['crimeDesc']);
    $crimeLocationTown = addslashes($_POST['crimeLocationTown']);
    $crimeLocationState = addslashes($_POST['crimeLocationState']);
    $locationLatLng = addslashes($_POST['locationLatLng']);
    
    echo $name;
    echo $crimeType;
    echo $crimeDesc;
    echo $crimeLocationTown;
    echo $crimeLocationState;
    echo $locationLatLng;
    
    //set the database connection variables
    $dbHost = "localhost";
    $dbUser = "test";
    $dbPass = "testtest";
    $dbDatabase = "testdb";
      
    //$reportDate = date("Y-m-d");
    //connect to the database
    $db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");
    mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");
    
    $query ="insert into userReport (reportPerson,crimeType,crimeDesc,crimeLocationTown,crimeLocationState,locationLatLng) values 
    ('$name','$crimeType','$crimeDesc','$crimeLocationTown','$crimeLocationState','$locationLatLng')";
    
    mysql_query($query) or die('Error, insert query failed');
    
    
    echo 'data inserted';
       
      
    
    ?>
    if it's on my local server, it will return 'data inserted'. but if i put it on my hosting, it will return 'insert query failed'. my other php page which also go insert query works well, but not this page. is it possible if I mis-constructed the mysqsl table on my hosting? but i've triple check the table and it's the same as the mysql table on my pc.

    please help. thanks a lot
    Last edited by imin; February 18th, 2008 at 01:13 AM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured