Jump to content

Search the Community

Showing results for tags 'php ajax json mysql'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hello to everybody! I am total lost. What is wrong? I try to INSERT INTO mysql. It add a row in MySQL , but no data. I am sitting since some days on it and dont understand it. I checked houndreds of web pages. I need help!!! ... Here is the full code: //+++++++++++++++++++++++++++++++++++++++++++++++++ Javascript: //+++++++++++++++++++++++++++++++++++++++++++++++++ function jsRecordInsertWrite() { var jsObject = { "ID": document.form_articles.ID.value, "Item": document.form_articles.Item.value, "ItemNo": document.form_articles.ItemNo.value, "Material": document.form_articles.Material.value, "Age": document.form_articles.Age.value, "ItemSize": document.form_articles.ItemSize.value, "Price": document.form_articles.Price.value, "Info": document.form_articles.Info.value, "InfoRed": document.form_articles.InfoRed.value, "ArrivalDate": document.form_articles.ArrivalDate.value, "ArrivalDateShown": document.form_articles.ArrivalDateShown.value, "MainPicLink": document.form_articles.MainPicLink.value, "ItemCondition": document.form_articles.ItemCondition.value, "ItemTimestamp": document.form_articles.ItemTimestamp.value, "ItemCategory": document.form_articles.ItemCategory.value }; // ... the AJAX request is successful var updatePage = function (response) { alert("insert record successful"); }; // ... the AJAX request fail var printError = function (req, status, err) { alert("insert record failed"); }; // Create an object to describe the AJAX request $.ajax({ url : 'insertarticle.php', dataType : 'json', contentType: 'application/json; charset=UTF-8', // This is the money shot data : jsObject, type : 'POST', success: updatePage, error: printError }); } //+++++++++++++++++++++++++++++++++++++++++++++++++ Here is insertarticle.php //+++++++++++++++++++++++++++++++++++++++++++++++++ <?php $link = mysql_connect('localhost', 'admin0', 'star1star1star0'); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db('sob', $link); if (!$db_selected) { die ('Can\'t use foo : ' . mysql_error()); } //read the json file contents $ID = $_POST['ID']; $Item = $_POST['Item']; $ItemNo = $_POST['ItemNo']; $Material = $_POST['Material']; $Age = $_POST['Age']; $ItemSize = $_POST['ItemSize']; $Price = $_POST['Price']; $Info = $_POST['Info']; $InfoRed = $_POST['InfoRed']; $ArrivalDate = $_POST['ArrivalDate']; $ArrivalDateShown = $_POST['ArrivalDateShown']; $MainPicLink = $_POST['MainPicLink']; $ItemCondition = $_POST['ItemCondition']; $ItemTimestamp = $_POST['timestamp']; $ItemCategory = $_POST['ItemCategory']; //insert into mysql table $sql = "INSERT INTO articles(ID, Item, ItemNo, Material, Age, ItemSize, Price, Info, InfoRed, ArrivalDate, ArrivalDateShown, MainPicLink, ItemCondition, ItemTimestamp, ItemCategory) VALUES (NULL,'$Item','$ItemNo','$Material','$Age','$ItemSize','$Price','$Info','$InfoRed','$ArrivalDate','$ArrivalDateShown','$ MainPicLink','$ItemCondition',NULL,'$ItemCategory')"; if(!mysql_query($sql)) { die('Error : ' . mysql_error()); } //database connection close mysql_close($link); //} ?> //+++++++++++++++++++++++++++++++++++++++++++++++++ The first NULL is for autoincrement ID, the other NULL is for automatic timestamp
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.