Jump to content

Updating a MySQL table, request, show, e.t.c HELP!


Koone

Recommended Posts

alright, let's start with snippets of code.

[code] function addNewUser($username, $password, $steamid, $email) {
global $db;
$time = time();
$q = "INSERT INTO `users` (`username`,`password`,`userlevel`,`userdata`,`email`,`timestamp`,`banned`, `steamid`) VALUES ('$username','$password','1','a:2:{s:4:\"user\";b:1;s:3:\"foo\";s:3:\"bar\";}','$email','$time',0)";
return $db->query($q);
}
function updateUserField($username, $field, $value) {
global $db;
$q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'";
return $db->query($q);
}
function getUserInfo($username) {
global $db;
$result = $db->query("SELECT * FROM ".TBL_USERS." WHERE username = '$username'");
if(!$result || ($db->num($result) < 1)) return NULL;
return $db->fetch($result);
}[/code]

Now, all of these work fine and everything, but the thing is, is that it's a framework, and I'm implementing it into my current design/layout. I have no idea what I'm doing, but taking a gander at the code and having a few friends teach me it, it's rather simple, ALTHOUGH... the problem I'm having is adding custom fields to the framework, and getting it to do these three functions. Look at $steamid, this is one var I want to add.

I can get $steamid to show up in the paages when I insert them manually in my MySQL database, it's just not wanting to register/update itself, and that's what I need help on.

From roster.php: [code]<?php
if($form->num_errors > 0) echo "<p>Error with request, please ensure correct data input.</p>";
$result = $db->query("SELECT username,steamid,userlevel,email,timestamp,banned FROM ".TBL_USERS." ORDER BY userlevel DESC,username");
$num_rows = $db->num($result);
if(!$result || ($num_rows < 0)) echo "Error displaying info";
else if($num_rows == 0) echo "Database table empty";
else {
for($i=0; $i<$num_rows; $i++){
echo '<tr>
<td></td>
<td>'.mysql_result($result,$i,"username").'</td>
<td>'.mysql_result($result,$i,"steamid").'</td>
<td>'.mysql_result($result,$i,"email").'</td>
<td>'.date('jS F Y, h:i:s A',mysql_result($result,$i,"timestamp")).'</td>
</tr>';
}
}
?>[/code]

works fine! But, when I go to edit account (that works, too) it doesn't want to update it / insert it or make the magic happen. Guide me in fufilling your requests of what you need to look at. Basically it's just me adding new custom fields, and that I don't know how to get into.  ;D

Help will be appreciated, and will respond as soon as possible.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.