You are here: Code not working « PHP Programming Language « IT news, forums, messages
Code not working

Posted by paul on 12/13/48 11:49

Hi could anyone please help me. I am a newbie to php. I am using php4
and trying to put together some code to update a db but I am not having
much luck. This is the code I have come up with so far.

<?php

if (isset($_POST['submitted'])) { // if the form has been submitted
handle it

// check the required form fields.
if (!empty($_POST['JobNumber'])) {

// Include MYSQL info
require_once
'/home/e-smith/files/ibays/mct/cgi-bin/mysql_connect.inc.php';

// Create the query
$q = "INSERT INTO MyDB (JobNumber) VALUES ('{$_POST['JobNumber']}')";

// Execute the query
$r = mysql_query ($dbc, $q);

//print a message indicating success
if (mysql_affected_rows($dbc) == 1) {
echo '<b><font color="green">It Has Been entered!</font></b>';
} else {
echo '<b><font color="red">Sorry it has failed!</font></b>';
}

Close the connection
mysql_close($dbc)

} else { //print a message if they failed to enter a catagory
echo '<b><font color="red">You forgot to enter a value</font></b>';
}

} else {
?>

Add a new category to the Job Number:<br />
<form action="add_expense_category.php" method="post">
<input type="text" name="JobNumber" size="30" maxlength="30" /><br />
<input type="hidden" name="submitted" value="true" />
<input type="submit" name="submit" value="Submit!" />
</form>

<?php
}
?>

but for some reason it doesn't work. Am I missing something I have
looked over it 100 times but everything seems fine. Can anyone help me
out.

Thanks in advance
Paul

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация