Author |
Message |
Donovan
Client

Joined: Oct 07, 2003
Posts: 735
Location: Ohio
|
Posted:
Thu Jun 30, 2005 2:21 pm |
|
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");
?>
|
|
|
|
 |
 |
Manuel
Regular


Joined: May 28, 2005
Posts: 90
|
Posted:
Thu Jun 30, 2005 3:23 pm |
|
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 |
_________________ Only registered users can see links on this board! Get registered or login! |
|
|
 |
Donovan

|
Posted:
Thu Jun 30, 2005 7:42 pm |
|
Thanks,
But...this still isn't working.
hhmmmmm? |
|
|
|
 |
kguske
Site Admin

Joined: Jun 04, 2004
Posts: 6437
|
Posted:
Thu Jun 30, 2005 9:47 pm |
|
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...
Only registered users can see links on this board! Get registered or login! |
|
|
 |
Donovan

|
Posted:
Fri Jul 01, 2005 10:24 am |
|
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

|
Posted:
Fri Jul 01, 2005 12:43 pm |
|
You might need to change op to file. |
|
|
|
 |
Donovan

|
Posted:
Fri Jul 01, 2005 2:27 pm |
|
Didn't help.
I'll work on this later tonight. |
|
|
|
 |
Donovan

|
Posted:
Sat Jul 02, 2005 12:14 pm |
|
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();
}
|
|
|
|
|
 |
|