Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic newbie question

Status
Not open for further replies.

vaavi8r

Technical User
Joined
Nov 7, 2003
Messages
1
Location
US
OK, I am new to PHP and MySQL, so bear with me. What I am trying to do is write a script in PHP to allow my members to file a flight report and have it added to our database for viewing by themselves and others. I have the database setup properly and can add records using the MySQL Administrator that comes with my site, but I cannot get this script to work. I get no errors, but the information is not recorded in the database.

Using MySQL 3.23.56 and PHP 4.2.2

The script.php looks like this:

<?php
$db = mysql_connect(&quot;localhost&quot;, &quot;tddftegh&quot;,&quot;scarlet&quot;);
mysql_select_db(&quot;margaritaair_com&quot;,$db);
$sql = &quot;INSERT INTO flightlog (macid, name, date, type, departure, destination, time, charterdoll, comment) VALUES ('$macid', '$name', '$date','$type','$departure','$destination','$time','$charterdoll','$comment')&quot;;
$result = mysql_query($sql);
if ($result) {
echo (&quot;PIREP recorded successfully&quot;);
} else {
echo(&quot;An error has occurred&quot;);
}

MySQL_close()
?>


And the html form looks like this:

<HTML>
<HEAD>
<BODY background=&quot;sky01.jpg&quot;>
<TITLE>PIREP INPUT FORM</TITLE>

<form method=&quot;post&quot; action=&quot;script.php&quot;>
MACID: <input type=&quot;text&quot; name=&quot;macid&quot;><br>
Name: <input type=&quot;text&quot; name=&quot;name&quot;><br>
Date of Flight: <input type=&quot;text&quot; name=&quot;date&quot;><br>
Type of Flight: <input type=&quot;text&quot; name=&quot;type&quot;><br>
Departure: <input type=&quot;text&quot; name=&quot;departure&quot;><br>
Destination: <input type=&quot;text&quot; name=&quot;destination&quot;><br>
Charter Pay: <input type=&quot;text&quot; name=&quot;charterdoll&quot;><br>
Comment: <input type=&quot;text&quot; name=&quot;comment&quot;><br>

<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;SUBMIT &quot;>
</form>
</html>

Again,I know this is basic stuff, but I cannot find out in any of my documentation why this is not working.

Thanks
Todd
 
Possibly a variable scope thing? register_globals, etc. Try using the $_POST['macid'] method of referring to your variables and you may have better luck.

Probably a copy/paste error, but also noticed:
MySQL_close();

Sorry, my php is weak.

----
JBR
 
flugh:
MySQL_close() is fine. Although variable names are case-sensitive, function names are not.


vaavi8r:
I have a FAQ on debugging PHP code in this forum: faq434-2999

It talks about the register_globals problem.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top