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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert to mysql isnt working

Status
Not open for further replies.

dunskii

Programmer
Sep 14, 2001
107
0
0
AU
hello,

i'm trying to add data collected from a form into a db. No errors are showing, but the data isnt being added to the db.

also, when the process is finished the page is not being redirected.

heres the code that i'm using.

<?php

$db = mysql_connect(&quot;localhost&quot;, &quot;root&quot;);

mysql_select_db(&quot;fjc&quot;,$db);

$barrister = mysql_query(&quot;INSERT INTO barristers (bar_id, fst_name, lst_name, floor, phone, year, file, created, modified) VALUES ('','$first_name', '$last_name', '$floor', '$phone', '$year', '$file', NOW(), NOW())&quot;,$db);

?>


<?php

$db = mysql_connect(&quot;localhost&quot;, &quot;root&quot;);

mysql_select_db(&quot;fjc&quot;,$db);

$admis_id=$_GET[admis_id]?$_GET[admis_id]:0;
$admissions = mysql_query(&quot;INSERT INTO bar_admis (bar_id, admis_id) VALUES (LAST_INSERT_ID(), '$admis_id')&quot;,$db);

?>

<?php

$db = mysql_connect(&quot;localhost&quot;, &quot;root&quot;);

mysql_select_db(&quot;fjc&quot;,$db);

$area_id=$_GET[area_id]?$_GET[area_id]:0;
$area = mysql_query(&quot;INSERT INTO bar_area (bar_id, area_id) VALUES (LAST_INSERT_ID(), '$area_id')&quot;,$db);

?>

<?php
header(&quot;Location: ?>


thanks for all your help

dunskii
 
you are not being redirected cause of all that blank lines between php tags.

to use Header you MAY NOT have any output, neither blank spaces.

why it is not inserting, you must echo the queries and then go to mysql and execute them there to check the error.
Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
The first thing I notice regarding the MySQL calls is that you're hitting your MySQL server as root with no password. If that's how your server is set up, okay . . . I hope it's a test server and not something publicly available.

On each of your calls, just put in an echo statement to use as a debugger. For instance, after the connection call, add this:

echo &quot;Database connection == $db&quot;;

If you don't get a resource identifier, you're not connecting at all to the database. Do this for $admissions on your insert statement as well.

--Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top