Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
Donovan
Client



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Sat Dec 16, 2006 8:29 pm Reply with quote

I have been struggling with this for days. The correct values are displayed in the form. I am passing them with hidden fields.

Even though I don't think I need to.

But I can't get either one of these to write to the database. I need help.

I'll link a txt file.
[ Only registered users can see links on this board! Get registered or login! ]
 
View user's profile Send private message Visit poster's website ICQ Number
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sat Dec 16, 2006 10:32 pm Reply with quote

Change this line
$result = $db->sql_query ("INSERT INTO " . $prefix . "_eto_tracking (log_id, ateam_id, dteam_id, tid, move_dt, action)". "VALUES ('NULL','$ateam_id','$dteam_id','$tid',CURRENT_TIMESTAMP(),'$action')");

To
$sql = "INSERT INTO " . $prefix . "_eto_tracking (log_id, ateam_id, dteam_id, tid, move_dt, action) VALUES (NULL,'$ateam_id','$dteam_id','$tid',CURRENT_TIMESTAMP(),'$action')";
echo '$sql = '.$sql;
die();
$result = $db->sql_query ($sql);

See what $sql looks like and if it seems ok then run the $sql directly in phpmyadmin.
 
View user's profile Send private message
Donovan







PostPosted: Sat Dec 16, 2006 10:53 pm Reply with quote

Here is what came back.

$sql = INSERT INTO nuke_eto_tracking (log_id, ateam_id, dteam_id, tid, move_dt, action) VALUES (NULL,'','','',CURRENT_TIMESTAMP(),'Attack')
 
Raven







PostPosted: Sat Dec 16, 2006 11:03 pm Reply with quote

I just noticed something? Where is your closing </form> statement Wink
 
Donovan







PostPosted: Sat Dec 16, 2006 11:12 pm Reply with quote

&^%#!

That still didn't help, but good catch.
 
Raven







PostPosted: Sat Dec 16, 2006 11:20 pm Reply with quote

Have you verified that those variables that you want to write have values? It could be the SQL statement is correct but the $_POST values are empty. We need to isolate where it's happening before resolving what is happening.
 
Donovan







PostPosted: Sat Dec 16, 2006 11:31 pm Reply with quote

I know the SQL is correct because the page displays the correct values.

Image

I don't think I need to pass the hidden values because they are not really hidden. I was trying to anyway.

Code:
echo"<input type=\"hidden\" name=\"ateam_id\" value=\"$ateam_id\">"

."<input type=\"hidden\" name=\"dteam_id\" value=\"$dteam_id\">"
."<input type=\"hidden\" name=\"tid\" value=\"$tid\">"


And Iv'e always written this way. I don't know how else to do it.

Code:
if ($op == "ConfirmAttack") {        

      $ateam_id = $_POST['team_id']; 
      $dteam_id = $_POST['dteam_id']; 
      $tid = $_POST['tid'];    
 
Raven







PostPosted: Sat Dec 16, 2006 11:57 pm Reply with quote

But, are there values here:

if ($op == "ConfirmAttack") {
$ateam_id = $_POST['team_id'];
$dteam_id = $_POST['dteam_id'];
$tid = $_POST['tid'];
 
Donovan







PostPosted: Sun Dec 17, 2006 12:09 am Reply with quote

No. I've tried this and get nothing.

Code:


if ($op == "ConfirmAttack") {        
      $ateam_id = $_POST['team_id']; 
      $dteam_id = $_POST['dteam_id']; 
      $tid = $_POST['tid'];    
      $action = 'Attack';   

      echo $ateam_id;
      echo $dteam_id;
      echo $tid;
      die();
 
Raven







PostPosted: Sun Dec 17, 2006 12:14 am Reply with quote

So, we know that the problem is that the values aren't getting passed, not in the writing to the database. Please post your latest code in the TXT file, with the closing </form> statement.
 
Donovan







PostPosted: Sun Dec 17, 2006 12:25 am Reply with quote

Done
 
Raven







PostPosted: Sun Dec 17, 2006 12:26 am Reply with quote

Right before this statement
echo"<input type=\"hidden\" name=\"ateam_id\" value=\"$ateam_id\">"

Check all the values. I believe you will find they are either empty or are equal to the LAST record you read, which is not what I think you are after.
 
Donovan







PostPosted: Sun Dec 17, 2006 12:33 am Reply with quote

Outside the loop like this?

Closetable();
}

echo $ateam_id;
echo $dteam_id;
echo $tid;

echo"<input type=\"hidden\" name=\"ateam_id\" value=\"$ateam_id\">"
."<input type=\"hidden\" name=\"dteam_id\" value=\"$dteam_id\">"
."<input type=\"hidden\" name=\"tid\" value=\"$tid\">"
."<input type=\"hidden\" name=\"div_id\" value=\"$div_id\">"
."<input type=\"hidden\" name=\"op\" value=\"ConfirmAttack\">"
."</form>";
@include_once("footer.php");
 
Raven







PostPosted: Sun Dec 17, 2006 12:35 am Reply with quote

Yep
 
Donovan







PostPosted: Sun Dec 17, 2006 12:41 am Reply with quote

It returns 14512748

145 is the id of $ateam_id

127 is the id of the last row in the query for $dteam_id and belong to the 2nd Armored Division

48 is the tid of the territory I'm on called Lincolnshire
 
Raven







PostPosted: Sun Dec 17, 2006 12:51 am Reply with quote

Are those the values you want to pass?
 
Donovan







PostPosted: Sun Dec 17, 2006 12:59 am Reply with quote

The first and third one are, but the middle one being the dteam_id should depend on which one I click on. Look at the graphic about 9 posts up.
 
Raven







PostPosted: Sun Dec 17, 2006 1:05 am Reply with quote

Just try $_GET['op'] in place of $op to humor me Smile
 
Donovan







PostPosted: Sun Dec 17, 2006 1:12 am Reply with quote

Nope. $action and CURRENT_TIMESTAMP() still get posted along with the $log_id but none of the other values.
 
Raven







PostPosted: Sun Dec 17, 2006 1:16 am Reply with quote

Just as an fyi, remove the quotes from around NULL. I've got to goto bed. It's something simple - I'm just too tired to look at it anymore. The print is all running together. I'll check back in the morning.
 
Donovan







PostPosted: Sun Dec 17, 2006 1:19 am Reply with quote

Hitting the pillow myself. Thanks for your help.
 
Raven







PostPosted: Sun Dec 17, 2006 1:20 am Reply with quote

When you look at the source code for the page when you call it up, are the hidden values populated correctly?
 
Donovan







PostPosted: Sun Dec 17, 2006 1:30 am Reply with quote

The are populated.

It looks right except for the dteam_id that's contained in the last dteam_id in the query

<input type="hidden" name="ateam_id" value="145">
<input type="hidden" name="dteam_id" value="127">
<input type="hidden" name="tid" value="48">
<input type="hidden" name="div_id" value="2">
<input type="hidden" name="op" value="ConfirmAttack">
</form>
 
Raven







PostPosted: Sun Dec 17, 2006 4:06 am Reply with quote

Please zip up and send me the page source. Thanks.
 
Donovan







PostPosted: Sun Dec 17, 2006 11:24 am Reply with quote

You mean the db tables?
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©