Here is my connection script (conn_inc.php):
<?php
# conn_inc.php
$connection=mysql_pconnect("localhost","mysuperusername","mypassword");
if (!$connection) {
echo "Could not connect to MySQL server!";
exit;
}
$db=mysql_select_db("test_gotcha",$connection);
if (!$db) {
echo "Could not change into the database test_gotcha";
exit;
}
?>
Here is a web form (g_add_gotcha.php -- I have inserted a space around
each " < > "s, hoping it will not render as html in your email
program):
< HTML >
< BODY >
<?php
# g_add_system.php
include ("conn_inc.php");
include ("g_common_func.php");
header1();
title("Add a new technical system area");
$sql="SELECT system_type FROM system";
$mysql_result=mysql_query($sql,$connection);
$num_rows=@mysql_num_rows($mysql_result);
echo "< FORM METHOD=GET ACTION=\"g_write_system.php\" >";
echo "<B>What is the new system < /B >< BR >
< INPUT TYPE=\"TEXT\" NAME=\"system\" >< BR >";
if ( $num_rows == 0 ) {
echo "There are currently no entries in the system table<BR>";
} else {
# we have some records
echo "< B >Here are the existing entries in the system table < /B >< BR
>";
echo "< SELECT NAME=\"current_system\" >";
while ($row=mysql_fetch_array($mysql_result))
{
$system_type=$row["system_type"];
# display results
echo "< OPTION >$system_type";
}
echo "< /SELECT >";
} # end else
echo "< BR >< BR >";
echo "< INPUT TYPE=\"SUBMIT\" VALUE=\"Add the new System\" >";
echo "< BR >< BR >< INPUT TYPE=\"RESET\" VALUE=\"Clear me!\" >";
mysql_close($connection);
?>
< /FORM >
<?php
main_menu_scr();
footer();
?>
< /BODY >
< /HTML >
Thanks for any help,
Ted
>> From: Colleen Dick <platypus@stripped>
>> Date: November 24, 2003 10:24:05 AM EST
>> To: tlr7425@stripped>> Cc: MySQL List <mysql@stripped>
>> Subject: Re: web data entry problem
>> Reply-To: platypus@stripped>>
>> There could be a number of things going on.
>> It would help troubleshoot your problem if your
>> script check for errors and print them if there are any. You cant
>> just assume a connection is being made just because phpmyadmin
>> connects.
>> Your web app has to make its own connection.
>> So how about showing us one of your scripts. I bet it is something
>> simple youre overlooking in your setup.
>>
>> tlr7425@stripped wrote:
>>> I hope someone might be willing to help out.
>>> I'm trying [still] to learn MySQL and php - to create some simply
>>> web based database.
>>> I have installed quite a few php/MySQL web database apps from books,
>>> however, none of them will get data entered into my database.
>>> When I create the database exactly as instructed, everything works
>>> great, but when I create the form to send/add a new record to my db
>>> then look at the db the new data is not there.
>>> This happens repeatedly with every example I build. I can add
>>> records using a terminal or phpMyAdmin.
>>> I'm running MySQL 4.0.14, Mac OS X 10.3, PHP 4.3.2.
>>> I installed 'tasks' -
>>> http://www.versiontracker.com/dyn/moreinfo/macosx/17996>>> and it works just fine! but it is too big for me to use to compare
>>> to my very simple scripts.
>>> Here is one I have recently installed whose data will not enter:
>>> http://hotwired.lycos.com/webmonkey/99/21/index3a_page4.html?>>> tw=programming
>>> I believe my db connection is being made (I may be wrong), after all
>>> my phpMyAdmin app also works fine.
>>> I would be very grateful is there might be a kind soul who would
>>> work with me to help me to find out what is wrong? I have had dbs
>>> before that worked fine, I don't understand this problem at all.
>>> Thanks,
>>> Ted
>>

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.