Ravens PHP Scripts: Forums
 

 

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



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

PostPosted: Thu Jun 30, 2005 2:21 pm Reply with quote

Anything wrong with this code?

Code:
$result = $db->sql_query("UPDATE " . $prefix . "_milpacs_sotm SET (uniqueid = '$uniqueid', citation = '$citation', criteria = '$criteria')");


It is not updating the table.

Here is the meat of the code.

Code:
//finds the server's root directory

$self = dirname(__FILE__);
$nukemod = basename($self);
$rootdir = eregi_replace("/modules/$nukemod", "", $self);
require_once("mainfile.php");
@include_once("header.php");
$module_name = basename(dirname(__FILE__));
global $module_name, $dbi, $prefix;

   Opentable();

if ($op == "editsotm") {
   // Validations go here
   // If all validations passed, save and exit, otherwise, redisplay with errors   
   $uniquied = intval($POST['$uniqueid']);   
   $citation = ($POST['$citation']);   
   $criteria = ($POST['$criteria']);   
   $result = $db->sql_query("UPDATE " . $prefix . "_milpacs_sotm SET (uniqueid = '$uniqueid', citation = '$citation', criteria = '$criteria')");

   $result = $db->sql_query($sql);
      echo "<META HTTP-EQUIV=\"refresh\" content=\"0;URL=modules.php?name=MILPACS&file=sotm\">";
}

?>
<form name="editsotm" action="modules.php?name=MILPACS" method="post">
<H3><center>Soldier of the Month</center></H3>
<HR>
<?php
$result = $db->sql_query("SELECT mm.name, sotm.citation, sotm.criteria FROM " . $prefix . "_milpacs_members mm JOIN " . $prefix . "_milpacs_sotm sotm WHERE mm.uniqueid = sotm.uniqueid");
$info = $db->sql_fetchrow($result);
if (!$result) {
    echo("<p>Error performing query: " . mysql_error() . "</p>");
    exit();
}

?>
<table border=0 width="100%" cellpadding="5">
<select name="uniqueid" size="1" align="center">
   <option value="">--- Select Soldier ---</option>
<?php
$result = $db->sql_query("SELECT uniqueid, name, status, rank_id FROM " . $prefix . "_milpacs_members WHERE status = 'Active' OR status = 'LOA' ORDER BY rank_id ASC");

while ( $row = $db->sql_fetchrow($result) ) {
   $name = $row["name"];
   $uniqueid = $row["uniqueid"];   
   echo "<option value='$uniqueid'>$name</option>";
   }
?>
      </select>
<br><br>
<tr>
<th width="15%"><b>Citation</b></th><td align="left" width="15%">
<textarea name="citation" cols="90" colspan="1" rows="4"><?php echo $info[citation] ?></textarea>
</td>
</tr>
<tr>
<th width="15%">Criteria</th><td align="left" width="15%">
<textarea name="criteria" cols="90" colspan="1" rows="4"><?php echo $info[criteria] ?></textarea>
</td>
</tr>
</table>
<input type="hidden" name="op" value="editsotm"/>
<input class="button" type="submit" align="center" value="Update"/>
</form>
<?php
CloseTable();
@include_once("footer.php");
?>
 
View user's profile Send private message Visit poster's website ICQ Number
Manuel
Regular
Regular



Joined: May 28, 2005
Posts: 90

PostPosted: Thu Jun 30, 2005 3:23 pm Reply with quote

you have declared $dbi in globals but you use $db

global $module_name, $dbi, $prefix;

should be

global $module_name, $dbi, $prefix, $db;

remove $dbi if you don't use

_________________
Image 
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Donovan







PostPosted: Thu Jun 30, 2005 7:42 pm Reply with quote

Thanks,

But...this still isn't working.


hhmmmmm?
 
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6433

PostPosted: Thu Jun 30, 2005 9:47 pm Reply with quote

What error message(s) are you seeing?

Trying changing:
Code:
SET (uniqueid = '$uniqueid', citation = '$citation', criteria = '$criteria')


To:
Code:
SET uniqueid = '$uniqueid', citation = '$citation', criteria = '$criteria'


(ie, remove the parentheses from the set clause).

_________________
I search, therefore I exist...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG
 
View user's profile Send private message
Donovan







PostPosted: Fri Jul 01, 2005 10:24 am Reply with quote

Thanks Kevin,

Another question. I am having the same problem as before and can't seem to fix it.

I have editsotm.php in the admin folder with

Code:
case "editsotm":

      @include_once("admin/editsotm.php");
      break;


in the index.php

I have
Code:


<input type="hidden" name="op" value="editsotm">
<input class="button" type="submit" align="center" value="Change"/>


at the bottom of the Milpacs/admin.php

Then I have

Code:
<?php

$result = $db->sql_query("SELECT mm.name, msotm.citation, msotm.criteria FROM " . $prefix . "_milpacs_members mm JOIN " . $prefix . "_milpacs_sotm msotm WHERE mm.uniqueid = msotm.uniqueid");
$info = $db->sql_fetchrow($result);
if (!$result) {
    echo("<p>Error performing query: " . mysql_error() . "</p>");
    exit();
}
if ($op == "editsotm") {
   echo "<URL=modules.php?name=MILPACS&op=editsotm>";   
}
?>


Which should open the editsotm.php in the admin forlder so I can edit the table.

All I get when I click on the change button is

Quote:
Sorry, that module file was not found!


I added $module_name inside my function

function milpacs() {
global $db, $prefix, $module_name;

Or I ws getting

Quote:
"Sorry, that module is not active"


Or something like that.

Anyway...I still can't access my editsotm.php which is inside my MILPACS/admin folder.

I can access it if I put it just in MILPACS.
 
kguske







PostPosted: Fri Jul 01, 2005 12:43 pm Reply with quote

You might need to change op to file.
 
Donovan







PostPosted: Fri Jul 01, 2005 2:27 pm Reply with quote

Didn't help.

I'll work on this later tonight.
 
Donovan







PostPosted: Sat Jul 02, 2005 12:14 pm Reply with quote

The uniqueid is being updated and set to the new value, but the other two are not.

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

   // Validations go here
   // If all validations passed, save and exit, otherwise, redisplay with errors   
   $uniquied = intval($POST['$uniqueid']);   
   $citation = ($POST['$citation']);   
   $criteria = ($POST['$criteria']);   
   $result = $db->sql_query("UPDATE " . $prefix . "_milpacs_sotm SET uniqueid = '$uniqueid', citation = '$citation', criteria = '$criteria'");
if (!$result) {
   die('Could not query:' . mysql_error());
   exit();
}
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL

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 ©