Hi,
I am experiencing table crash problem in my sql.. I have insert code that cause the table crash.. see this code -
$a = mysql_query("INSERT INTO online(session_id,odate) VALUES('$sess','NOW()')");
-
@mysql_free_result($a);
-
whats wrong with this? before this code I was simply executing mysql_query(...) .. I thought this could be due to not releasing resultset.
Any help will be much appreciated..
Thanks,
Moazam
7 2105
Hi,
I am experiencing table crash problem in my sql.. I have insert code that cause the table crash.. see this code -
$a = mysql_query("INSERT INTO online(session_id,odate) VALUES('$sess','NOW()')");
-
@mysql_free_result($a);
whats wrong with this? before this code I was simply executing mysql_query(...) .. I thought this could be due to not releasing resultset.
Any help will be much appreciated..
Thanks,
Moazam
What kind of table crash is this? have you lost any records or....
Atli 5,058
Expert 4TB
Hi Moazam. Welcome to The Scripts!
What do you mean by 'table crash'?
The only thing I can see wrong there is that you use quote-marks around the NOW() function, which you shouldn't. Quote-marks should only be used with string values and dates.
Also, if the session_id is really an ID, I would assume it is an Integer? If so then you should not use quote-marks in that either.
Hi,
I am experiencing table crash problem in my sql.. I have insert code that cause the table crash.. see this code -
$a = mysql_query("INSERT INTO online(session_id,odate) VALUES('$sess','NOW()')");
-
@mysql_free_result($a);
whats wrong with this? before this code I was simply executing mysql_query(...) .. I thought this could be due to not releasing resultset.
Any help will be much appreciated..
Thanks,
Moazam
I think we are all confused as to the problem you are having. One thing to note is that the @ symbol in front of mysql_free_result will prevent any error from being presented to the screen.
Sorry for creating confusion.. here is the actual code -
<?php
-
function fill_online() {
-
global $USER, GET_CONFIG;
-
$query = "SELECT * FROM online WHERE `session_id` = '" . session_id() . "'";
-
$result = mysql_query( $query );
-
-
$ip = $_SERVER['REMOTE_ADDR'];
-
$page = $_SERVER['REQUEST_URI'];
-
$browser = $_SERVER['HTTP_USER_AGENT'];
-
-
if( $result && mysql_num_rows( $result ) )
-
{
-
$user_field = '';
-
if($USER!= '') {
-
$user_field = "`user`='$USER',";
-
}
-
else {
-
$user_field = "`user`='',";
-
}
-
$query = "UPDATE `online`
-
SET
-
$user_field
-
`browser` = '$browser',
-
`ip` = ' $ip',
-
`time` = '".date("YmdHi")."'
-
WHERE `session_id` = '" . session_id() . "'";
-
mysql_query($query);
-
}
-
else {
-
if ($USER!= '') {
-
$query = "INSERT INTO `online` (`session_id`, `user`, `time`, `ip`, `browser`, `page`)
-
VALUES('".session_id()."','$USER','". date( "YmdHi" )."','$ip','$browser','$page')";
-
}
-
else {
-
$query = "INSERT INTO `online` (`session_id`, `time`, `ip`, `browser`, `page`)
-
VALUES('".session_id()."', '". date( "YmdHi" )."','$ip','$browser','$page')";
-
}
-
mysql_query($query);
-
}
-
@mysql_free_result($result);
-
-
//DELETE
-
$now = date("YmdHi"); // yyyymmddhhmm, ex. 200009021431
-
$timer_ago = date("YmdHi", mktime(date("H"), date("i") - $GET_CONFIG['max_time_online'], 0,
-
date("m"), date("d"), date("Y")));
-
$query = "DELETE FROM `online` WHERE `time` < '" . $timer_ago ."'";
-
mysql_query($query);
-
-
}
-
?>
works fine with 100+ online users at a time.. but when user number grows.. table online crash.. and mysql says Table 'online' is marked as crashed and should be repaired
thats what I am doing all the time
Heya, moazam.
Try backing up your database, deleting it and recreating it.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Lenz Grimmer |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
MySQL 4.0.14, a new version of the popular Open Source/Free Software
Database, has been released. It is now available in source and binary...
|
by: Ka |
last post by:
I install a mysql server in default installation with latin charset, but
I want to use GBK(a chinese charset), so that I can store and
search chinese words directly.
so, I download, unpack and...
|
by: Henry Hank |
last post by:
Environment:
I'm setting up a database server on a Dell Poweredge 2650, dual 1.8GHZ pentium
with 1GB of memory and RAID5 drives. I've installed RedHat 9, and updated the
kernel to 2.4.20-19.9smp....
|
by: Johannes B. Ullrich |
last post by:
--=-WKgoK98ejo9BZyGYc3N/
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
I am having problems with MySQL 4.0.12 on RedHat Advanced Server 2.1
using a dual Xeon with 8...
|
by: Shashikant Kore |
last post by:
Hi,
I am using MySQL for a table which will have 100M+ records, avg length
of records being 130 bytes.
When the number of records reach approx. 25M (and the file size close
to 4GB), the rate of...
|
by: pratchaya |
last post by:
This is my sample error in my MySQL Log
New value of fp=(nil) failed sanity check, terminating stack trace!
Please read http://www.mysql.com/doc/en/Using_stack_trace.html and
follow instructions...
|
by: tomzam |
last post by:
I'm trying to get mysql working on Fedora Core 4. Actually trying
to start the program mysqld without fatal errors. I posted this message
first on the linux misc group - but no luck so far. Maybe...
|
by: Me Alone |
last post by:
Hello:
I am trying to edit some C code I found in "The definitive guide to
using, programming, and administering MySQL" by Paul DuBois. This C
client program connects and then segfaults when...
|
by: alf |
last post by:
Hi,
is it possible that due to OS crash or mysql itself crash or some e.g.
SCSI failure to lose all the data stored in the table (let's say million
of 1KB rows). In other words what is the worst...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |