• Advertisement

Archived

This topic is now archived and is closed to further replies.

PHP Help - Involves MySQL

This topic is 5105 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright, my problem is that I've got a script where I can add an article to the database. But...when I submit the form, I get no message saying whether the query failed or was a success. Here's my source:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<?php
require ("config.inc");
?>
<title> Add An Article </title>
</head>

<?php

// If the form was submitted, process it

if (isset($submit))
{
$query = "insert into articles values ('0', '$article_name', '$type_id', '$system_id' '$year', '$month', '$day')";
if (@mysql_query ($query))
{
echo 'The article has been added';
}
else
{
echo 'The title could not be added.' . mysql_error();
}
}
?>

<form action="<?=$PHP_SELF ?>" method="post">
Game:   <input type="text" name="article_name" size="50" maxlength="100" /> <br />
Type:   <select name="type_id"> <option> Select The Type Of Article </option>

<?php
// Print all the types

$query1 = "SELECT type_id, type FROM types";
$query_result1 = @mysql_query ($query1);
while ($row1 = @mysql_fetch_array ($query_result1))
{
echo "<option value=\"$row1[type_id]\"> $row1[type] </option>\n";
}
?>
</select> <br />

System: <select name="system_id"> <option> Select The System </option>

<?php
// Print all the systems

$query2 = "SELECT system_id, system FROM systems";
$query_result2 = @mysql_query ($query2);
while ($row2 = @mysql_fetch_array ($query_result2))
{
echo "<option value=\"$row2[system_id]\"> $row2[system] </option>\n";
}
?>
</select> <br />

Date Entered:

<select name="year"> <option> Year </option>
<?php
// Print the years

$year = 2003;
while ($year <= 2004)
{
print ("<option value=\"$year\"> $year </option> <br />");
$year++;
}
?>
</select>

<select name="month"> <option> Month </option>
<?php
// Print all the month nubmers

$month = 0;
while ($month <= 12)
{
print ("<option value=\"$month\"> $month </option> <br />");
$month++;
}
?>
</select>

<select name="day"> <option> Day </option>
<?php
// Print all the day number

$day = 0;
while ($day <= 31)
{
print ("<option value=\"$day\"> $day </option> <br />");
$day++;
}
?>
</select> <br />

<input type="submit" name="submit" value="Submit!" />
</form>
</body>
</html>
config.inc just has my connection to the database. I konw for a fact it's not a connection problem because the

Share this post


Link to post
Share on other sites
Advertisement
*sigh* Now I have another problem I can't seem to figure out. I'm getting the following error:

Column count doesn't match value count at row 1  


Here is the SQL code for the table that's being modified:


CREATE TABLE articles
(
article_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
article VARCHAR (255),
type_id INT UNSIGNED,
system_id INT UNSIGNED,
year INT UNSIGNED,
month INT UNSIGNED,
day INT UNSIGNED,
PRIMARY KEY (article_id),
INDEX (article)
);


[edited by - Ekim_Gram on March 5, 2004 4:03:53 PM]

Share this post


Link to post
Share on other sites

$query = "insert into articles values ('0', '$article_name', '$type_id', '$system_id' '$year', '$month', '$day')";
if (@mysql_query ($query))


Possible missing a , between system_id and year?



[edited by - acraig on March 5, 2004 4:08:13 PM]

Share this post


Link to post
Share on other sites

  • Advertisement