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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:39:46+00:00 2026-05-28T03:39:46+00:00

I am trying to retrieve the ID of the submitted data that the user

  • 0

I am trying to retrieve the ID of the submitted data that the user enters then display it using jQuery/Ajax. The idea is to display the link of the data or, “quote” page. “Your quote was submitted! Click [link] to go to the page” The link would look like this: http://example.com/quote-123. 123 being the ID of the quote.

This is the part I am using to submit the data using ajax and jQuery.

$(document).delegate("'#submit-quote'", "submit", function(){
        var quoteVal = $(this).find('[name="quote"]').val();
        $.post("add.php", $(this).serialize(), function(data) {
            var like = $('.quote-wrap span iframe');
            $('.inner').prepend('<div class="quote-wrap group">' + like + '<div class="quote"><p>' + quoteVal+ '</p></div></div>');
            // console.log("success");
            var id = parseInt(data);
            alert(id);
        });
        return false;
    });

alert(id) returns NaN.

add.php:

require('inc/connect.php');


    $quote = $_POST['quote'];
    $quotes = mysql_real_escape_string($quote);

    //echo $quotes . "Added to database";

    mysql_query("INSERT INTO entries (quote) VALUES('$quotes')")
    or die(mysql_error());
    echo mysql_insert_id($quote);

I am new to JavaScript and PHP and I’m really trying to learn and understand it. How can I get the id from the submitted quote?

  • 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-05-28T03:39:47+00:00Added an answer on May 28, 2026 at 3:39 am

    The error in your pastie code says:

    Warning: mysql_insert_id() expects parameter 1 to be resource, string given in C:\wamp\www\virallikesproject\add.php on line 12
    

    The resource it is expecting is the link identifier returned by mysql_connect() which I don’t see in your code. Regardless, the mysql_insert_id() behavior if you DONT pass it a resource is to use the last one opened.

    Changing this line:

    mysql_insert_id($quote);
    

    to this:

    mysql_insert_id();
    

    should take care of that error. As far as the overall issue, I’m concerned because I don’t see where you are connecting to your database at all.

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

Sidebar

Related Questions

I am trying to retrieve a column from another related table, and display that
I'm trying to create a form using method=post . When it's submitted, the data
I'm trying to retrieve data that's put outside element blocks. Sample; <td> <b>abc</b> 123
I am trying to retrieve the value of a dictionary key and display that
im trying to retrieve some data using a reader in vb.net. I dont have
Trying to retrieve data using linq from a database. I would like to use
I am trying to retrieve Tiff image data through COM using a StringBuilder but
Im trying to retrieve data from http://www.facebook.com/ajax/shares/view/?target_fbid=410558838979218&__a=1 I get mix of js and html
Trying to retrieve related data from the relationships table, after user clicks on the
I am trying to retrieve data from an XML file that is not located

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.