Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8337723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:22:50+00:00 2026-06-09T04:22:50+00:00

I have a INSERT operation in my website which works like this. On index.html

  • 0

I have a INSERT operation in my website which works like this.

  1. On index.html file when a button is pressed a javascript function is called.
  2. In the javascript function AJAX is used to send the request to the php file with necessary parameters
  3. The php file accesses the database inserts data.

For your reference here is the code for the above tasks.

2.Javascript function

function grandFinale()
{
        if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    //document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","insert.php?q=&name=" + encodeURIComponent(document.getElementById('name').value) + "&txtScore1=" + encodeURIComponent(document.getElementById('txtScore1').innerHTML),true);
xmlhttp.send();
document.location.reload();

}

1.HTML button

<p id="txtScore1" align="center" style="color: #cc6699; font-size: 18px; "></p>
<label class="control-label" for="input01">Name</label>
<a href="#" class="btn btn-primary" onclick="javascript:grandFinale()" >Submit My Score</a>

3.PHP Script

<?php
    $con = mysql_connect("host","uname","pword");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

    mysql_select_db("dbname", $con) or die( "Unable to select database");

    $sql="INSERT INTO 'masterTable' ('Name', 'Score') VALUES ('{$_GET['name']}','{$_GET['txtScore1']}')";

    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "1 record added";

    mysql_close($con);
    ?>

Things work fine when I try locally on harddisk but after I host it on 000webhost.com the INSERT doesnt work. Can you suggest where I went wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:22:52+00:00Added an answer on June 9, 2026 at 4:22 am

    I would first check to see if the user you have set up for the database (uname) on 000webhost.com has INSERT privileges.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an insert query that gets generated like this INSERT INTO InvoiceDetail (LegacyId,InvoiceId,DetailTypeId,Fee,FeeTax,Investigatorid,SalespersonId,CreateDate,CreatedById,IsChargeBack,Expense,RepoAgentId,PayeeName,ExpensePaymentId,AdjustDetailId)
Using POSIX threads & C++, I have an Insert operation which can only be
I would like to have an insert and update if exists operation on my
I want to have an insert tab button for my UITextView so that users
I have to insert 8000+ records into a SQLite database using Django's ORM. This
I have to perform a bulk operation bool AddEntitiesX(List<X>) : For each insert of
I have three button INSERT,EDIT and DELETE on sample.aspx page in .net application.I am
I have a website I've built in VS2005, C#, .NET 2.0. This website does
I have a doubt regarding database operation.I have one insert query that should run
I have a schema, with a document structure that looks like this: { _id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.