Jump to content

My MYSQL add data to MYSQL table script


winmastergames

Recommended Posts

Your Probely Wondering why im posting alot of threads well ive got heaps of new stuff in PHP and ill make a very big website script So thats why im here

 

Ok well online i found a way to add Data into MYSQL tables but ive edited to what i need but it doesnt work so yea here it is It just doesnt put any data into the table

you need to goto script.php?user=tablenamehere for it to work

 

<?php
$swduser = $_GET["user"];
$titleadd = $_POST["titleadd"];
$sloganadd = $_POST["sloganadd"];
$con = mysql_connect("localhost","root","mypass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("swd-dbweb", $con);

mysql_query("INSERT INTO $swduser (title, slogan) 
VALUES ('$titleadd', 'sloganadd')");

mysql_close($con);
?>
<p><a href="enable.php?user=<?php echo $_GET["user"]; ?>">Enable Website Making</a>
<p><a href="disable.php?user=<?php echo $_GET["user"]; ?>">Disable Website Making</a>
  
  </p>
<form action="makewebsite.php" method="post">
<p>Title:
  <input type="text" name="titleadd" id="titleadd" />
</p>
<p>Slogan:
  <input type="text" name="sloganadd" id="sloganadd" />
</p>
<input type="submit" />
</form>

Link to comment
Share on other sites

Well im not to sure how and where to add it heres the script with the code that mmarif4u said to add

<?php
$swduser = $_GET["user"];
$titleadd = $_POST["titleadd"];
$sloganadd = $_POST["sloganadd"];
$con = mysql_connect("localhost","root","com12345");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("swd-dbweb", $con);

$query="INSERT INTO $swduser (title, slogan) VALUES ('$titleadd', '$sloganadd')";
$run=mysql_query($query) or die (mysql_error());

mysql_close($con);
?>
<p><a href="enable.php?user=<?php echo $_GET["user"]; ?>">Enable Website Making</a>
<p><a href="disable.php?user=<?php echo $_GET["user"]; ?>">Disable Website Making</a>
  
  </p>
<form action="makewebsite.php" method="post">
<p>Title:
  <input type="text" name="titleadd" id="titleadd" />
</p>
<p>Slogan:
  <input type="text" name="sloganadd" id="sloganadd" />
</p>
<input type="submit" />
</form>

And i get this error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(title, slogan) VALUES ('ttt', 'sss')' at line 1

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.