troubleshooting Question

how to create table in mysql

Avatar of JohnLourdu
JohnLourduFlag for Afghanistan asked on
Web Languages and StandardsPHPWeb Servers
8 Comments1 Solution495 ViewsLast Modified:
Hi experts,

As per below mysql query how to create table in mysql using terminal:
db1.php
<?php
      //database connection
      mysql_connect("localhost", "root", "sam123") or die(mysql_error());
      mysql_select_db("test") or die(mysql_error());
?>

save.php

<?php
      include("db1.php");
      $content = $_POST['content']; //get posted data
      $content = mysql_real_escape_string($content);      //escape string      
      
      $sql = "UPDATE content SET text = '$content' WHERE element_id = '1' ";
      
      if (mysql_query($sql)) {
            echo 1;
      }
?>

ajax in main.html

$("#libary-save-ico").click(function (e) {
$(".savebtn").hide();
var content = $('body').html();
$.ajax({
url: 'save.php',
type: 'POST',
data: {
content: content
},
success:function (data) {
if (data == '1') {
$("#curEditStatus")
.addClass("success")
.html("Data saved successfully")
.fadeIn('slow')
.delay(3000)
.fadeOut('slow');
}
else {
$("#curEditStatus")
.addClass("error")
.html("Error, data could not be saved")
.fadeIn('slow')
.delay(3000)
.fadeOut('slow');
}
}
});
});

            <?php
                  //get data from database.
                  include("db1.php");
                  $sql = mysql_query("select text from content where element_id='1'");
                  $row = mysql_fetch_array($sql);                  
                  echo $row['text'];
            ?>            

Regards,
John.A
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros