add entry fails ?

I want the webpage to add an entry to a MySQL database table, on submit.
The following .htm and php fails to add an entry to the table, but does not
generate an error. What is the problem ?
  <TITLE>Add Log Entry</TITLE>
  <H1>Add an Entry</H1>
  <form method="POST" action="add.php">
   <input type="text" name="entry"><br>
   <b>log Entry:</b><br>
   <textarea cols="60" rows="6" name="entrytext"> 
  <input type="submit" name="submit" value="Submit">
.... add.php....
  if ($HTTP_POST_VARS['submit']) {
    $query ="INSERT INTO weblog (entrytitle,entrytext)";
    $query.=" VALUES ('$entrytitle','$entrytext')";
    if ($result) 
	echo "<b>Successful</b>";

Open in new window

Who is Participating?
Loganathan NatarajanConnect With a Mentor LAMP DeveloperCommented:
Ok,  what version of PHP you use? please create phpinfo.php and check it.

Then you can


print_r ($_POST);


echo phpinfo();

Open in new window

Loganathan NatarajanLAMP DeveloperCommented:
Try to change this line and check it

$result=mysql_query($query) or die("Could not insert, the error details,".mysql_error());

Open in new window

Loganathan NatarajanLAMP DeveloperCommented:
also check on the php page whether you receive all the posted values...

print_r ($HTTP_POST_VARS);

Open in new window

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

pillmillAuthor Commented:
I changed the $result and added a check on the posted values.

There is no output from -
print_r ($HTTP_POST_VARS);

The changed $result also produces no result.  The database is still not updated.

Any other possibilities ?
Is your code block at all getting hit? What I mean is:
  if ($HTTP_POST_VARS['submit']) {
Is this IF condition getting satisfied? Did you check server configuration? Perhaps you can see this:

print_r ($_POST);

Does this return anything?

pillmillAuthor Commented:
Thanks. Here is the information from phpinfo():

 PHP Version => 5.2.6 System => Windows NT SYSTEM 5.1 build 2600
Build Date => May 2 2008 18:01:20
Configure Command => cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared" "--with-extra-includes=
C:\Program Files (x86)\Microsoft SDK\Include;
C:\Program Files (x86)\Microsoft SDK\Lib;C:\PROGRA~2\MICROS~2\VC98\LIB;C:\PROGRA~2\MICROS~2\VC98\MFC\LIB"
Server API => Command Line Interface Virtual Directory Support => enabled Configuration File (php.ini)
Path => C:\WINDOWS Loaded Configuration File => C:\wamp\bin\php\php5.2.6\php.ini
PHP API => 20041225 PHP Extension => 20060613 Zend Extension => 220060519
Debug Build => no Thread Safety => enabled Zend Memory Manager => enabled IPv6 Support =>
enabled Registered PHP Streams => php, file, data, http, ftp, compress.zlib
Registered Stream Socket Transports => tcp, udp Registered Stream Filters => convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*
pillmillAuthor Commented:
I tried to test _POST.
It fails to return a value in this simple example:
What is the problem ?
   <form action="process.php" method="post">
    Name: <input type="text" name="emp_name"/>
    Salary: <input type="text" name="emp_sal"/>
    <input type="submit" value="submit"/>
  echo "emp name is : " . $_POST['emp_name'] . "<br/>";
  echo "salary is : " . $_POST['emp_sal']; 

Open in new window

Loganathan NatarajanLAMP DeveloperCommented:
Can  you check whether register_global= is ON OR OFF???
pillmillAuthor Commented:
PHP Core
Directive	Local Value	Master Value
allow_call_time_pass_reference	Off	Off
allow_url_fopen	On	On
allow_url_include	Off	Off
always_populate_raw_post_data	Off	Off
arg_separator.input	&	&
arg_separator.output	&	&
asp_tags	Off	Off
auto_append_file	no value	no value
auto_globals_jit	On	On
auto_prepend_file	no value	no value
browscap	no value	no value
default_charset	no value	no value
default_mimetype	text/html	text/html
define_syslog_variables	Off	Off
disable_classes	no value	no value
disable_functions	no value	no value
display_errors	On	On
display_startup_errors	Off	Off
doc_root	no value	no value
docref_ext	no value	no value
docref_root	no value	no value
enable_dl	On	On
error_append_string	no value	no value
error_log	c:/wamp/logs/php_error.log	c:/wamp/logs/php_error.log
error_prepend_string	no value	no value
error_reporting	6135	6135
expose_php	On	On
extension_dir	c:/wamp/bin/php/php5.2.6/ext/	c:/wamp/bin/php/php5.2.6/ext/
file_uploads	On	On	#FFFFFF	#FFFFFF
highlight.comment	#FF8000	#FF8000
highlight.default	#0000BB	#0000BB
highlight.html	#000000	#000000
highlight.keyword	#007700	#007700
highlight.string	#DD0000	#DD0000
html_errors	On	On
ignore_repeated_errors	Off	Off
ignore_repeated_source	Off	Off
ignore_user_abort	Off	Off
implicit_flush	Off	Off
include_path	.;C:\php5\pear	.;C:\php5\pear
log_errors	On	On
log_errors_max_len	1024	1024
magic_quotes_gpc	Off	Off
magic_quotes_runtime	Off	Off
magic_quotes_sybase	Off	Off
mail.force_extra_parameters	no value	no value
max_execution_time	30	30
max_input_nesting_level	64	64
max_input_time	60	60
memory_limit	128M	128M
open_basedir	no value	no value
output_buffering	4096	4096
output_handler	no value	no value
post_max_size	8M	8M
precision	14	14
realpath_cache_size	16K	16K
realpath_cache_ttl	120	120
register_argc_argv	Off	Off
register_globals	Off	Off
register_long_arrays	Off	Off
report_memleaks	On	On
report_zend_debug	On	On
safe_mode	Off	Off
safe_mode_exec_dir	no value	no value
safe_mode_gid	Off	Off
safe_mode_include_dir	no value	no value
sendmail_from	no value	no value
sendmail_path	no value	no value
serialize_precision	100	100
short_open_tag	Off	Off
SMTP	localhost	localhost
smtp_port	25	25
sql.safe_mode	Off	Off
track_errors	Off	Off
unserialize_callback_func	no value	no value
upload_max_filesize	2M	2M
upload_tmp_dir	c:/wamp/tmp	c:/wamp/tmp
user_dir	no value	no value
variables_order	GPCS	GPCS
xmlrpc_error_number	0	0
xmlrpc_errors	Off	Off
y2k_compliance	On	On
zend.ze1_compatibility_mode	Off	Off
Apache Version 	Apache/2.2.8 (Win32) PHP/5.2.6 JRun/4.0
Apache API Version 	20051115 

Open in new window

pillmillAuthor Commented:
When I run the program and enter data in the
two textboxes, then press submit, it returns:

"; echo "salary is : " . $_POST['emp_sal']; ?>
Loganathan NatarajanLAMP DeveloperCommented:

How did you fix this issue?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.