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 8754827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:43:01+00:00 2026-06-13T13:43:01+00:00

I’m running through a tutorial that is a little dated, but I’ve tried to

  • 0

I’m running through a tutorial that is a little dated, but I’ve tried to improve the code and make it up-to-date.

The code is well commented and easy to follow, but I saw use of things like the <b> tag, which I think it deprecated, making me think it was a bit old…. And I also wonder, why is DB.php included, when there’s a connect command, already, in the php file?

Please, have a look at the code and tell me why it isn’t working?

Here is the html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="/javascript/jquery-1.8.2.js"></script>
<script type="text/javascript" src="phpmysql.js"></script>
</head>
<body>

  <!-----------------------------------------------------------------------
  1) Create some html content that can be accessed by jquery
  ------------------------------------------------------------------------>
  <h2> Bookstore example </h2>
  <h3>Output: </h3>
  <div id="output">Will you look at some books?</div>
  <button>click</button>
  </body>
</html>

And the js:

$(document).ready.(
  function () 
  {
    $("button").click.(function()
    {
      //---------------------------------------------------------------------
      // 2) Send a http request with AJAX http://api.jquery.com/jQuery.ajax/
      //---------------------------------------------------------------------
      $.ajax({                                      
        url: 'form3.php',   //the script to call to get data          
        data: "",       //you can insert url argumnets here to pass to api.php
                        //for example "id=5&parent=6"
        dataType: 'json',                //data format      
        success: function(data)          //on recieve of reply
        {
          var id = data[0];              //get id
          var vname = data[1];           //get name
          //------------------------------------------------------------------
          // 3) Update html content
          //------------------------------------------------------------------
          $('#output').html("<p>Title: </p>"+id+"<p> Content: </p>"+vname); //Set output element html
        } 
      });
    }); 
  });

And the php:

<?php 

  //--------------------------------------------------------------------------
  // Example php script for fetching data from mysql database
  //--------------------------------------------------------------------------
  $host = "localhost";
  $user = "username";
  $pass = "password";

  $databaseName = "auto_try";
  $tableName = "books";

  //------------------------------------------------------------------------
  // 1) Connect to mysql database
  //------------------------------------------------------------------------
  include 'DB.php';
  $con = mysql_connect($host,$user,$pass);
  $dbs = mysql_select_db($databaseName, $con);

  //------------------------------------------------------------------------
  // 2) Query database for data
  //------------------------------------------------------------------------
  $result = mysql_query("SELECT * FROM $tableName");      //query
  $array = mysql_fetch_row($result);                      //fetch result    

  //------------------------------------------------------------------------
  // 3) echo result as json 
  //------------------------------------------------------------------------
  echo json_encode($array);
  • 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-13T13:43:02+00:00Added an answer on June 13, 2026 at 1:43 pm

    your js jquery function was wrong try this,there is no . after ready or click

     $(document).ready(
          function () 
          {
            $("button").click(function()
            {.....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.