View Single Post
  #6 (permalink)  
Old 11-04-2008, 12:12 PM
robeysan robeysan is offline
Registered User
 
Join Date: Oct 2008
Posts: 4
I change my code so the ...

dbConnector and settings all come from the same script. (Any suggestions as to whay this is a bad ideal?) I did this to avoid the earlier stated problems i was having.

Code:
<html>
<head>
<title>New Article</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php
$username = "00011";
$password = "quzar12s";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
  or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
$title = $HTTP_POST_VARS['title'];
$tagline = $HTTP_POST_VARS['tagline'];
$section = $HTTP_POST_VARS['section'];
$thearticle = $HTTP_POST_VARS['thearticle'];

echo $title;
echo $tagline;
echo $section;
echo $thearticle;

$query = "INSERT INTO cmsarticles (title, tagline, section, thearticle) VALUES 
	('$title', '$tagline', '$section', '$thearticle')";
mysql_query($query) or die('Error, insert query failed');

?>



<body>
<form name="form1" method="post" action="newArticle.php">
        <p>&nbsp;Title:
          <input name="title" type="text" id="title">
        </p>
        <p>&nbsp;Tagline:
          <input name="tagline" type="text" id="tagline">
        </p>
        <p>&nbsp;Section:
          <input name="section" type="text" id="section">
        </p>
        <p>&nbsp;Article:
          <textarea name="thearticle" cols="50" rows="6" id="thearticle"></textarea>
        </p>
        <p align="center">
          <input type="submit" name="Submit" value="Submit">
        </p>
</form>
</body>
</html>

This is the newArticle.php file I am currently using. When it runs I get an error message that says the insert query fails, why?

The echo command succesfully output the contents of the post btw.

Last edited by robeysan; 11-04-2008 at 12:16 PM.
Reply With Quote