Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Still to new to PHP to know what's wrong
Old 04-12-2005, 02:04 PM Still to new to PHP to know what's wrong
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
Hello,

I need extensive help yet again, and since you people seem to know what you’re doing I am relying on your expertise.

I have a form; this form (form2) is on the bottom of a page that displays the results from another form (form1). The results from form1 show me in information in the database including the record number. Form 2 is suppose to allow me to enter in the record number of any particular row and insert a date from the second and last field in the form.

For example if the record ID I enter is 15 and the date is 04/11/2005 I would like to enter this information into the form have a query see the record ID I have entered, find it in the database and insert the date into the database field Date_Sent.

The problem I am having is the forms and search results query’s are working find but the database is not being updated with the date from form 2, Please help and idiot find his way.

Form2

PHP Code:
<form method="POST" action="search_results.php" name="search_results">
<table width="69%"  align="center" border="0" cellspacing="4">
  <tr>
    <td width="26%"><div align="right">Update Record Number </div></td>
    <td width="30%">
      <div align="center">
        <input type="text" name="ID">
      </div></td>
    <td width="15%"><div align="right">With Date </div></td>
    <td width="29%"><div align="center"><input id="demo1" type="text" size="25"><a href="javascript:NewCal('demo1','mmmddyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>

</div></td>
  </tr>
</table>
<br>

<div align="center">
  <input type="submit" value="Update the database" name="search">
</div>
</form>
<?php
if (isset($_POST['Submit'])) {
include(
'mysql_connect_register.php');
$sql "select * from accounts where ID = {$_POST['ID']}";
$result mysql_query($sql);
$sql_update "insert into accounts where ID = {$_POST['ID']}, Date_Sent Values ('{$_POST['demo1']}')";
$query_run;
}
?>
merlin is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-12-2005, 02:14 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
SQL Syntax error, do it this way:
PHP Code:
$frm_ID $_POST['ID'];
$frm_demo1 $_POST['demo1'];

$query "UPDATE accounts SET 
   Date_Sent='
$frm_demo1',
   WHERE ID = 
$frm_ID";

$result mysql_query($query
I set the form values into prefixed variables so you won't get escape errors, and corrected your SQL syntax, should work now, unless i've read everything wrong
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by leavethisplace; 04-12-2005 at 02:16 PM..
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-12-2005, 02:15 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
One more thing!

PHP Code:
$sql "select * from accounts where ID = {$_POST['ID']}"
Take that out, I can't see a use for it and I think you've got it there through confusion
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-12-2005, 02:27 PM
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
Sorry man, I made the changes as you pointed out but still no change. Here's my code.
PHP Code:
<?php
if (isset($_POST['Submit'])) {

$frm_ID $_POST['ID']; 
$frm_demo1 $_POST['demo1']; 

$query "UPDATE accounts SET Date_Sent='$frm_demo1', WHERE ID = $frm_ID"
$result mysql_query($query);
$query_run;
}

mysql_close();
?>
merlin is offline
Reply With Quote
View Public Profile
 
Old 04-12-2005, 02:36 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
PHP Code:
$query "UPDATE accounts SET Date_Sent='$frm_demo1' WHERE ID = $frm_ID"
Didnt mean to put that Comma there, it should work. What does it output? and what should it output?
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-12-2005, 02:42 PM
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
It should only update the Date_Sent field with a date (inputed by the user) for the record number inputed.
merlin is offline
Reply With Quote
View Public Profile
 
Old 04-12-2005, 02:59 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
Did u take that comma out? The SQL statement is correct.

check that you're values are actually coming through, place a load of echo's before the script, just to make sure.
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-12-2005, 03:41 PM
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
I Got It Weeeeeeeee
merlin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Still to new to PHP to know what's wrong
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.07457 seconds with 12 queries