mySQL database UPDATE table SET.... help
- mykh
- Novice


- Joined: Oct 25, 2003
- Posts: 16
- Status: Offline
Quote:
<?php
error_reporting(E_ALL);
session_start();
include("top.php");
$id = $_SESSION["id"];
//echo $id;
$conn = mysql_connect("localhost","adm","******") or die(mysql_error());
$db = mysql_select_db("fs",$conn) or die(mysql_error());
$result = mysql_query("UPDATE users SET username='$username' WHERE id='$id'") or die(mysql_error());
echo "<p>Done!";
echo "<p>< a href='account.php'>Back To Account< /a>";
echo "<br>< a href='main.php'>Warehouse< /a>";
echo "<br>< a href='index.php'>Home< /a>";
include("bottom.php");
?>
error_reporting(E_ALL);
session_start();
include("top.php");
$id = $_SESSION["id"];
//echo $id;
$conn = mysql_connect("localhost","adm","******") or die(mysql_error());
$db = mysql_select_db("fs",$conn) or die(mysql_error());
$result = mysql_query("UPDATE users SET username='$username' WHERE id='$id'") or die(mysql_error());
echo "<p>Done!";
echo "<p>< a href='account.php'>Back To Account< /a>";
echo "<br>< a href='main.php'>Warehouse< /a>";
echo "<br>< a href='index.php'>Home< /a>";
include("bottom.php");
?>
could someone please tell me what is wrong with this, because it won't do what i ask it to (update selected row in table)please tell me whats wrong with it, or an alternative solution
btw I never get any errors while running this script, thats the scariest part of all, it wont work and wont show errors
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
October 25th, 2003, 7:20 pm
- Bigwebmaster
- Site Admin


- Joined: Dec 20, 2002
- Posts: 8922
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
Well I would try getting rid of the ' around your variables in the mysql query statement. So instead of using:
I would use:
Usually when you put single quots around variables they will not be replaced with the actual value of the variable. I am not sure if that is causing your problem, but I would try that first. I have a feeling that is your problem though, because that would explain why you get no errors. It is simply doing nothing because it cannot find any id that matches '$id' since that isn't being replaced with anything (it just stays as $id literally). Let us know what happens!
Code: [ Select ]
UPDATE users SET username='$username' WHERE id='$id'
I would use:
Code: [ Select ]
UPDATE users SET username=$username WHERE id=$id
Usually when you put single quots around variables they will not be replaced with the actual value of the variable. I am not sure if that is causing your problem, but I would try that first. I have a feeling that is your problem though, because that would explain why you get no errors. It is simply doing nothing because it cannot find any id that matches '$id' since that isn't being replaced with anything (it just stays as $id literally). Let us know what happens!
Ozzu Hosting - Want your website on a fast server like Ozzu?
- mykh
- Novice


- Joined: Oct 25, 2003
- Posts: 16
- Status: Offline
man, I was honestly praying to God that what you said would work, since if it works my whole game is set, I can make the rest of it no problem
but Newton's (or Murphy's) Law says" everything that can go wrong, will"
Error:
Unknown column 'test' in 'field list'
test is the username and when username=$username in the sql query, it thinks of $username as a column (at least thats what i figure) please help, open to any and all suggestions
or could someone psot a script they use to update db
but Newton's (or Murphy's) Law says" everything that can go wrong, will"
Error:
Unknown column 'test' in 'field list'
test is the username and when username=$username in the sql query, it thinks of $username as a column (at least thats what i figure) please help, open to any and all suggestions
or could someone psot a script they use to update db
- Bigwebmaster
- Site Admin


- Joined: Dec 20, 2002
- Posts: 8922
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
Show the new code that you were using that produced the error you said above.
Ozzu Hosting - Want your website on a fast server like Ozzu?
- mykh
- Novice


- Joined: Oct 25, 2003
- Posts: 16
- Status: Offline
Quote:
<?php
error_reporting(E_ALL);
session_start();
include("top.php");
$id = $_SESSION["id"];
//echo $id;
$conn = mysql_connect("localhost","adm","******") or die(mysql_error());
$db = mysql_select_db("fs",$conn) or die(mysql_error());
$result = mysql_query("UPDATE users SET username=$username WHERE id=$id") or die(mysql_error());
echo "<p>Done!";
echo "<p>< a href='account.php'>Back To Account< /a>";
echo "<br>< a href='main.php'>Warehouse< /a>";
echo "<br>< a href='index.php'>Home< /a>";
include("bottom.php");
?>
error_reporting(E_ALL);
session_start();
include("top.php");
$id = $_SESSION["id"];
//echo $id;
$conn = mysql_connect("localhost","adm","******") or die(mysql_error());
$db = mysql_select_db("fs",$conn) or die(mysql_error());
$result = mysql_query("UPDATE users SET username=$username WHERE id=$id") or die(mysql_error());
echo "<p>Done!";
echo "<p>< a href='account.php'>Back To Account< /a>";
echo "<br>< a href='main.php'>Warehouse< /a>";
echo "<br>< a href='index.php'>Home< /a>";
include("bottom.php");
?>
- Bigwebmaster
- Site Admin


- Joined: Dec 20, 2002
- Posts: 8922
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
I do not have an answer for you yet, but I just wanted to let you know that I replaced your password above in your code examples to ****** because I wasn't sure if you used fake credentials there. We do not need anyone trying to hack into your server. If that was your actual info you used, I would at least change that part before you post it here. Many of these posts can be viewed by thousands of people.
Ozzu Hosting - Want your website on a fast server like Ozzu?
- mykh
- Novice


- Joined: Oct 25, 2003
- Posts: 16
- Status: Offline
Bigwebmaster wrote:
I do not have an answer for you yet, but I just wanted to let you know that I replaced your password above in your code examples to ****** because I wasn't sure if you used fake credentials there. We do not need anyone trying to hack into your server. If that was your actual info you used, I would at least change that part before you post it here. Many of these posts can be viewed by thousands of people.
tnx, but dont u think i know that, that isnt a real server, it just a test server on my comp, so i dont bother replacing passwords and usernames
the real db on the website is completely different
- Bigwebmaster
- Site Admin


- Joined: Dec 20, 2002
- Posts: 8922
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
Well that is good to know, however, some people will suprise on what they will post so I was just taking precautions to protect you. (Just in case).
Ozzu Hosting - Want your website on a fast server like Ozzu?
- Bigwebmaster
- Site Admin


- Joined: Dec 20, 2002
- Posts: 8922
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
As far as you problem is concerned, this is how I usually use PHP to update the MySQL database:
Just so you know this requires some functions that I use from PHPBB to do it the way I do. You might download PHPBB to take a look at it.
Code: [ Select ]
$sql = "UPDATE users SET username = $username WHERE id = $id";
if ( !($result = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
}
if ( !($result = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
}
- $sql = "UPDATE users SET username = $username WHERE id = $id";
- if ( !($result = $db->sql_query($sql)) ) {
- message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
- }
Just so you know this requires some functions that I use from PHPBB to do it the way I do. You might download PHPBB to take a look at it.
Ozzu Hosting - Want your website on a fast server like Ozzu?
- mykh
- Novice


- Joined: Oct 25, 2003
- Posts: 16
- Status: Offline
tnx for the concern
well i tried it the way you did it
and it gave me this:
$result = mysql_query($sql);
Fatal error: Call to a member function on a non-object in c:\apache\htdocs\account_edit2.php on line 11
line 11 is the line where the if statement is placed
then i tried this
and it gives same error referring to the if statement, i tried altering it around a bit and it didnt work, please check, maybe u typed something wrong in there, i'm going back to looking for an answer to this
well i tried it the way you did it
Quote:
$sql = "UPDATE users SET username = $username WHERE id = $id";
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
}
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
}
and it gave me this:
$result = mysql_query($sql);
Fatal error: Call to a member function on a non-object in c:\apache\htdocs\account_edit2.php on line 11
line 11 is the line where the if statement is placed
then i tried this
Quote:
$sql = "UPDATE users SET username = $username WHERE id = $id";
$result = mysql_query($sql);
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
}
$result = mysql_query($sql);
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
}
and it gives same error referring to the if statement, i tried altering it around a bit and it didnt work, please check, maybe u typed something wrong in there, i'm going back to looking for an answer to this
- Bigwebmaster
- Site Admin


- Joined: Dec 20, 2002
- Posts: 8922
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
Well like I said, it requires some other functions that came with PHPBB to do it the way I did. You would need to get those functions. I am sure you probably do not need all this though, and you could probably do it without all the functions. However, if you look at the functions you might be able to figure out the correct way to do it. Here are the functions that come with PHPBB in the mysql.php file:
Code: [ Select ]
<?php
/***************************************************************************
* mysql.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: mysql.php,v 1.16 2002/03/19 01:07:36 psotfx Exp $
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
if(!defined("SQL_LAYER"))
{
define("SQL_LAYER","mysql");
class sql_db
{
var $db_connect_id;
var $query_result;
var $row = array();
var $rowset = array();
var $num_queries = 0;
//
// Constructor
//
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->password = $sqlpassword;
$this->server = $sqlserver;
$this->dbname = $database;
if($this->persistency)
{
$this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
}
else
{
$this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
}
if($this->db_connect_id)
{
if($database != "")
{
$this->dbname = $database;
$dbselect = @mysql_select_db($this->dbname);
if(!$dbselect)
{
@mysql_close($this->db_connect_id);
$this->db_connect_id = $dbselect;
}
}
return $this->db_connect_id;
}
else
{
return false;
}
}
//
// Other base methods
//
function sql_close()
{
if($this->db_connect_id)
{
if($this->query_result)
{
@mysql_free_result($this->query_result);
}
$result = @mysql_close($this->db_connect_id);
return $result;
}
else
{
return false;
}
}
//
// Base query method
//
function sql_query($query = "", $transaction = FALSE)
{
// Remove any pre-existing queries
unset($this->query_result);
if($query != "")
{
$this->num_queries++;
$this->query_result = @mysql_query($query, $this->db_connect_id);
}
if($this->query_result)
{
unset($this->row[$this->query_result]);
unset($this->rowset[$this->query_result]);
return $this->query_result;
}
else
{
return ( $transaction == END_TRANSACTION ) ? true : false;
}
}
//
// Other query methods
//
function sql_numrows($query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_num_rows($query_id);
return $result;
}
else
{
return false;
}
}
function sql_affectedrows()
{
if($this->db_connect_id)
{
$result = @mysql_affected_rows($this->db_connect_id);
return $result;
}
else
{
return false;
}
}
function sql_numfields($query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_num_fields($query_id);
return $result;
}
else
{
return false;
}
}
function sql_fieldname($offset, $query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_field_name($query_id, $offset);
return $result;
}
else
{
return false;
}
}
function sql_fieldtype($offset, $query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_field_type($query_id, $offset);
return $result;
}
else
{
return false;
}
}
function sql_fetchrow($query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$this->row[$query_id] = @mysql_fetch_array($query_id);
return $this->row[$query_id];
}
else
{
return false;
}
}
function sql_fetchrowset($query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
unset($this->rowset[$query_id]);
unset($this->row[$query_id]);
while($this->rowset[$query_id] = @mysql_fetch_array($query_id))
{
$result[] = $this->rowset[$query_id];
}
return $result;
}
else
{
return false;
}
}
function sql_fetchfield($field, $rownum = -1, $query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
if($rownum > -1)
{
$result = @mysql_result($query_id, $rownum, $field);
}
else
{
if(empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
{
if($this->sql_fetchrow())
{
$result = $this->row[$query_id][$field];
}
}
else
{
if($this->rowset[$query_id])
{
$result = $this->rowset[$query_id][$field];
}
else if($this->row[$query_id])
{
$result = $this->row[$query_id][$field];
}
}
}
return $result;
}
else
{
return false;
}
}
function sql_rowseek($rownum, $query_id = 0){
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_data_seek($query_id, $rownum);
return $result;
}
else
{
return false;
}
}
function sql_nextid(){
if($this->db_connect_id)
{
$result = @mysql_insert_id($this->db_connect_id);
return $result;
}
else
{
return false;
}
}
function sql_freeresult($query_id = 0){
if(!$query_id)
{
$query_id = $this->query_result;
}
if ( $query_id )
{
unset($this->row[$query_id]);
unset($this->rowset[$query_id]);
@mysql_free_result($query_id);
return true;
}
else
{
return false;
}
}
function sql_error($query_id = 0)
{
$result["message"] = @mysql_error($this->db_connect_id);
$result["code"] = @mysql_errno($this->db_connect_id);
return $result;
}
} // class sql_db
} // if ... define
?>
/***************************************************************************
* mysql.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: mysql.php,v 1.16 2002/03/19 01:07:36 psotfx Exp $
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
if(!defined("SQL_LAYER"))
{
define("SQL_LAYER","mysql");
class sql_db
{
var $db_connect_id;
var $query_result;
var $row = array();
var $rowset = array();
var $num_queries = 0;
//
// Constructor
//
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->password = $sqlpassword;
$this->server = $sqlserver;
$this->dbname = $database;
if($this->persistency)
{
$this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
}
else
{
$this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
}
if($this->db_connect_id)
{
if($database != "")
{
$this->dbname = $database;
$dbselect = @mysql_select_db($this->dbname);
if(!$dbselect)
{
@mysql_close($this->db_connect_id);
$this->db_connect_id = $dbselect;
}
}
return $this->db_connect_id;
}
else
{
return false;
}
}
//
// Other base methods
//
function sql_close()
{
if($this->db_connect_id)
{
if($this->query_result)
{
@mysql_free_result($this->query_result);
}
$result = @mysql_close($this->db_connect_id);
return $result;
}
else
{
return false;
}
}
//
// Base query method
//
function sql_query($query = "", $transaction = FALSE)
{
// Remove any pre-existing queries
unset($this->query_result);
if($query != "")
{
$this->num_queries++;
$this->query_result = @mysql_query($query, $this->db_connect_id);
}
if($this->query_result)
{
unset($this->row[$this->query_result]);
unset($this->rowset[$this->query_result]);
return $this->query_result;
}
else
{
return ( $transaction == END_TRANSACTION ) ? true : false;
}
}
//
// Other query methods
//
function sql_numrows($query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_num_rows($query_id);
return $result;
}
else
{
return false;
}
}
function sql_affectedrows()
{
if($this->db_connect_id)
{
$result = @mysql_affected_rows($this->db_connect_id);
return $result;
}
else
{
return false;
}
}
function sql_numfields($query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_num_fields($query_id);
return $result;
}
else
{
return false;
}
}
function sql_fieldname($offset, $query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_field_name($query_id, $offset);
return $result;
}
else
{
return false;
}
}
function sql_fieldtype($offset, $query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_field_type($query_id, $offset);
return $result;
}
else
{
return false;
}
}
function sql_fetchrow($query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$this->row[$query_id] = @mysql_fetch_array($query_id);
return $this->row[$query_id];
}
else
{
return false;
}
}
function sql_fetchrowset($query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
unset($this->rowset[$query_id]);
unset($this->row[$query_id]);
while($this->rowset[$query_id] = @mysql_fetch_array($query_id))
{
$result[] = $this->rowset[$query_id];
}
return $result;
}
else
{
return false;
}
}
function sql_fetchfield($field, $rownum = -1, $query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
if($rownum > -1)
{
$result = @mysql_result($query_id, $rownum, $field);
}
else
{
if(empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
{
if($this->sql_fetchrow())
{
$result = $this->row[$query_id][$field];
}
}
else
{
if($this->rowset[$query_id])
{
$result = $this->rowset[$query_id][$field];
}
else if($this->row[$query_id])
{
$result = $this->row[$query_id][$field];
}
}
}
return $result;
}
else
{
return false;
}
}
function sql_rowseek($rownum, $query_id = 0){
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_data_seek($query_id, $rownum);
return $result;
}
else
{
return false;
}
}
function sql_nextid(){
if($this->db_connect_id)
{
$result = @mysql_insert_id($this->db_connect_id);
return $result;
}
else
{
return false;
}
}
function sql_freeresult($query_id = 0){
if(!$query_id)
{
$query_id = $this->query_result;
}
if ( $query_id )
{
unset($this->row[$query_id]);
unset($this->rowset[$query_id]);
@mysql_free_result($query_id);
return true;
}
else
{
return false;
}
}
function sql_error($query_id = 0)
{
$result["message"] = @mysql_error($this->db_connect_id);
$result["code"] = @mysql_errno($this->db_connect_id);
return $result;
}
} // class sql_db
} // if ... define
?>
- <?php
- /***************************************************************************
- * mysql.php
- * -------------------
- * begin : Saturday, Feb 13, 2001
- * copyright : (C) 2001 The phpBB Group
- * email : support@phpbb.com
- *
- * $Id: mysql.php,v 1.16 2002/03/19 01:07:36 psotfx Exp $
- *
- ***************************************************************************/
- /***************************************************************************
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- ***************************************************************************/
- if(!defined("SQL_LAYER"))
- {
- define("SQL_LAYER","mysql");
- class sql_db
- {
- var $db_connect_id;
- var $query_result;
- var $row = array();
- var $rowset = array();
- var $num_queries = 0;
- //
- // Constructor
- //
- function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
- {
- $this->persistency = $persistency;
- $this->user = $sqluser;
- $this->password = $sqlpassword;
- $this->server = $sqlserver;
- $this->dbname = $database;
- if($this->persistency)
- {
- $this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
- }
- else
- {
- $this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
- }
- if($this->db_connect_id)
- {
- if($database != "")
- {
- $this->dbname = $database;
- $dbselect = @mysql_select_db($this->dbname);
- if(!$dbselect)
- {
- @mysql_close($this->db_connect_id);
- $this->db_connect_id = $dbselect;
- }
- }
- return $this->db_connect_id;
- }
- else
- {
- return false;
- }
- }
- //
- // Other base methods
- //
- function sql_close()
- {
- if($this->db_connect_id)
- {
- if($this->query_result)
- {
- @mysql_free_result($this->query_result);
- }
- $result = @mysql_close($this->db_connect_id);
- return $result;
- }
- else
- {
- return false;
- }
- }
- //
- // Base query method
- //
- function sql_query($query = "", $transaction = FALSE)
- {
- // Remove any pre-existing queries
- unset($this->query_result);
- if($query != "")
- {
- $this->num_queries++;
- $this->query_result = @mysql_query($query, $this->db_connect_id);
- }
- if($this->query_result)
- {
- unset($this->row[$this->query_result]);
- unset($this->rowset[$this->query_result]);
- return $this->query_result;
- }
- else
- {
- return ( $transaction == END_TRANSACTION ) ? true : false;
- }
- }
- //
- // Other query methods
- //
- function sql_numrows($query_id = 0)
- {
- if(!$query_id)
- {
- $query_id = $this->query_result;
- }
- if($query_id)
- {
- $result = @mysql_num_rows($query_id);
- return $result;
- }
- else
- {
- return false;
- }
- }
- function sql_affectedrows()
- {
- if($this->db_connect_id)
- {
- $result = @mysql_affected_rows($this->db_connect_id);
- return $result;
- }
- else
- {
- return false;
- }
- }
- function sql_numfields($query_id = 0)
- {
- if(!$query_id)
- {
- $query_id = $this->query_result;
- }
- if($query_id)
- {
- $result = @mysql_num_fields($query_id);
- return $result;
- }
- else
- {
- return false;
- }
- }
- function sql_fieldname($offset, $query_id = 0)
- {
- if(!$query_id)
- {
- $query_id = $this->query_result;
- }
- if($query_id)
- {
- $result = @mysql_field_name($query_id, $offset);
- return $result;
- }
- else
- {
- return false;
- }
- }
- function sql_fieldtype($offset, $query_id = 0)
- {
- if(!$query_id)
- {
- $query_id = $this->query_result;
- }
- if($query_id)
- {
- $result = @mysql_field_type($query_id, $offset);
- return $result;
- }
- else
- {
- return false;
- }
- }
- function sql_fetchrow($query_id = 0)
- {
- if(!$query_id)
- {
- $query_id = $this->query_result;
- }
- if($query_id)
- {
- $this->row[$query_id] = @mysql_fetch_array($query_id);
- return $this->row[$query_id];
- }
- else
- {
- return false;
- }
- }
- function sql_fetchrowset($query_id = 0)
- {
- if(!$query_id)
- {
- $query_id = $this->query_result;
- }
- if($query_id)
- {
- unset($this->rowset[$query_id]);
- unset($this->row[$query_id]);
- while($this->rowset[$query_id] = @mysql_fetch_array($query_id))
- {
- $result[] = $this->rowset[$query_id];
- }
- return $result;
- }
- else
- {
- return false;
- }
- }
- function sql_fetchfield($field, $rownum = -1, $query_id = 0)
- {
- if(!$query_id)
- {
- $query_id = $this->query_result;
- }
- if($query_id)
- {
- if($rownum > -1)
- {
- $result = @mysql_result($query_id, $rownum, $field);
- }
- else
- {
- if(empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
- {
- if($this->sql_fetchrow())
- {
- $result = $this->row[$query_id][$field];
- }
- }
- else
- {
- if($this->rowset[$query_id])
- {
- $result = $this->rowset[$query_id][$field];
- }
- else if($this->row[$query_id])
- {
- $result = $this->row[$query_id][$field];
- }
- }
- }
- return $result;
- }
- else
- {
- return false;
- }
- }
- function sql_rowseek($rownum, $query_id = 0){
- if(!$query_id)
- {
- $query_id = $this->query_result;
- }
- if($query_id)
- {
- $result = @mysql_data_seek($query_id, $rownum);
- return $result;
- }
- else
- {
- return false;
- }
- }
- function sql_nextid(){
- if($this->db_connect_id)
- {
- $result = @mysql_insert_id($this->db_connect_id);
- return $result;
- }
- else
- {
- return false;
- }
- }
- function sql_freeresult($query_id = 0){
- if(!$query_id)
- {
- $query_id = $this->query_result;
- }
- if ( $query_id )
- {
- unset($this->row[$query_id]);
- unset($this->rowset[$query_id]);
- @mysql_free_result($query_id);
- return true;
- }
- else
- {
- return false;
- }
- }
- function sql_error($query_id = 0)
- {
- $result["message"] = @mysql_error($this->db_connect_id);
- $result["code"] = @mysql_errno($this->db_connect_id);
- return $result;
- }
- } // class sql_db
- } // if ... define
- ?>
Ozzu Hosting - Want your website on a fast server like Ozzu?
- Bigwebmaster
- Site Admin


- Joined: Dec 20, 2002
- Posts: 8922
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
I looked a little more at your original script and I really do not see why that one shouldn't work. I went and viewed a few other sample scripts and they look simliliar to yours. Here is one I looked at:
It looks almost idential to yours, but the query is made in its own variable. Also have you already created the tables in your MySQL database that you are trying to update?
Code: [ Select ]
$mysql_link = mysql_connect("hostname", "username", "password");
$mysql_select_db("database", $mysql_link);
$query = "Update table set field2 = $name";
$result = mysql_query($query);
$mysql_select_db("database", $mysql_link);
$query = "Update table set field2 = $name";
$result = mysql_query($query);
- $mysql_link = mysql_connect("hostname", "username", "password");
- $mysql_select_db("database", $mysql_link);
- $query = "Update table set field2 = $name";
- $result = mysql_query($query);
It looks almost idential to yours, but the query is made in its own variable. Also have you already created the tables in your MySQL database that you are trying to update?
Ozzu Hosting - Want your website on a fast server like Ozzu?
- mykh
- Novice


- Joined: Oct 25, 2003
- Posts: 16
- Status: Offline
- mykh
- Novice


- Joined: Oct 25, 2003
- Posts: 16
- Status: Offline
- Bigwebmaster
- Site Admin


- Joined: Dec 20, 2002
- Posts: 8922
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
Have you tested to make sure data is stored in the $username and $id variables? In other words they are not blank correct? Also I know you said you had the MySQL table setup, but do you have an ID in that MySQL table that matches the ID that you are sending through the $id variable?
Also, what version of MySQL and PHP are you using?
Finally have you tried to run that MySQL query manually through MyPHPAdmin or some other interface if you have it, just to make sure it actually works on your database?
I am just shooting blanks in the dark here, since you really haven't provided me much to work with but your little snippet of code. Hopefully one of these blanks will hit something soon
Also, what version of MySQL and PHP are you using?
Finally have you tried to run that MySQL query manually through MyPHPAdmin or some other interface if you have it, just to make sure it actually works on your database?
I am just shooting blanks in the dark here, since you really haven't provided me much to work with but your little snippet of code. Hopefully one of these blanks will hit something soon
Ozzu Hosting - Want your website on a fast server like Ozzu?
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
October 31st, 2003, 6:58 pm
1, 2
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 27 posts
- Users browsing this forum: ScottG and 243 guests
- 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 post attachments in this forum
