Query error need help please

2004-09-14 Thread Soheil Shaghaghi
Hello.
I have a subroutine which checks for multiple entries and if a user has
voted once in the same day, it will not calculate the vote. However, I
found out that it does not really do this.
What it does is only look at the last entry. If the user IP address is
the last entry it does not calculate the vote, but if it is not, it goes
ahead and let the user vote.
So, basically it only looks at the very last entry.
Can someone please tell me what needs to be done to fix this?
Thanks so much.


if(isset($_POST['submit_rating'])  isset($_POST['user_id'])  
($_POST['submit_rating'] = 3  $_POST['submit_rating'] =
10)){

$user_id = (int) $_POST['user_id'];

if(isset($_SESSION['ra'])){
$_SESSION['ra'] .= $user_id . ,;
} else {
$_SESSION['ra'] = $user_id . ,;
}

$rating = (int) $_POST['submit_rating'];
$rater_id = isset($_SESSION['userid']) ? $_SESSION['userid'] :
0;

$check_ip_sql = 
select
*
from
$tb_ratings
where
user_id = '$user_id'
order by
timestamp desc
;

$check_ip_query = mysql_query($check_ip_sql) or
die(mysql_error());
$last_rater_ip = @mysql_result($check_ip_query, 0,
rater_ip);
$last_rater_id = @mysql_result($check_ip_query, 0,
rater_id);
$last_rated = @mysql_result($check_ip_query, 0, timestamp);

$yesterday = date(YmdHis,
mktime(date(H), date(i), date(s),
date(m), date(d)-10, date(Y)));

$same_ip = false;
$too_soon = false;
$same_user = false;

if($last_rater_ip == $HTTP_SERVER_VARS['REMOTE_ADDR']) $same_ip
= true;
if($last_rated  $yesterday) $too_soon = true;
if($user_id == $rater_id) $same_user = true;

if(!$same_user  (!$same_ip || !$too_soon)){
$rating_accepted = true;

$is_sql = 
insert into $tb_ratings (
id,
user_id,
rating,
rater_id,
rater_ip
) values (
'',
'$user_id',
'$rating',
'$rater_id',
'$_SERVER[REMOTE_ADDR]'
)
;

$is_query = mysql_query($is_sql) or die(mysql_error());

$gs_sql = 
select
total_ratings,
total_points,
average_rating
from
$tb_users
where
id = '$user_id'
;

$gs_query = mysql_query($gs_sql) or die(mysql_error());
$total_ratings = mysql_result($gs_query, 0,
total_ratings);
$total_points = mysql_result($gs_query, 0,
total_points);

$total_ratings++;
$total_points += $rating;
$average_rating = $total_points / $total_ratings;

$ps_sql = 
update
$tb_users
set
total_ratings = '$total_ratings',
total_points = '$total_points',
average_rating = '$average_rating'
where
id = '$user_id'
;

$ps_query = mysql_query($ps_sql) or die(mysql_error());

}
}



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Need help with a query

2003-12-27 Thread Soheil Shaghaghi
Hello everyone,
I need help with MySQL coding in php please if anyone can help.


I have 3 tables:
-users, where the user info is stored.
-awards: contains the list of all the awards for each user
-award_types: contains different types of award
The tables are at the bottom of the page.

What I need to do is look at these tables when a user id is being viewed and
display the awards image that the user has won.
A user can have multiple awards.


CREATE TABLE `award_types` (
  `id` tinyint(3) unsigned NOT NULL auto_increment,
  `award_type` varchar(255) NOT NULL default '',
  `award_image` varchar(250) default NULL,
  `gender` enum('m','f') NOT NULL default 'm',
  `order_by` tinyint(3) NOT NULL default '0',
  PRIMARY KEY  (`id`)
)

#
# Dumping data for table `award_types`
#

INSERT INTO `award_types` VALUES (1, 'November 2003', nov.gif, 'm', 0);
INSERT INTO `award_types` VALUES (2, 'December 2003', dec.gif, 'm', 1);
INSERT INTO `award_types` VALUES (3, 'January 2004', jan.gif, 'm', 2);
INSERT INTO `award_types` VALUES (4, 'February 2004', feb.gif, 'm', 3);


CREATE TABLE `awards` (
  `id` bigint(20) unsigned NOT NULL auto_increment,
  `user_id` bigint(20) NOT NULL default '0',
  `award_id` bigint(20) NOT NULL default '0',
  `chosen` varchar(20) NOT NULL default '',
  PRIMARY KEY  (`id`),
  KEY `id` (`id`),
  KEY `chosen` (`chosen`)
)

#
# Dumping data for table `awards`
#

INSERT INTO `awards` VALUES (1, 1, 1, 'enabled');
INSERT INTO `awards` VALUES (3, 1, 2, 'enabled');


CREATE TABLE `users` (
  `id` bigint(20) unsigned NOT NULL auto_increment,
  `username` varchar(16) NOT NULL default '',
  `password` varchar(16) NOT NULL default '',
  `hint` varchar(100) NOT NULL default '',
  `realname` varchar(48) NOT NULL default '',
  `description` text NOT NULL,
  `age` tinyint(2) unsigned NOT NULL default '0',
  `user_type` tinyint(3) unsigned NOT NULL default '0',
  `state` varchar(32) NOT NULL default '',
  `country` varchar(32) NOT NULL default 'United_States.gif',
  `email` varchar(48) NOT NULL default '',
  `url` varchar(255) NOT NULL default '',
  `quote` varchar(255) NOT NULL default '',
  `image` enum('here','there') NOT NULL default 'there',
  `image_url` varchar(144) NOT NULL default '',
  `image_ext` varchar(4) NOT NULL default '',
  `image_status` enum('enabled','disabled','queued','approved') NOT NULL
default 'enabled',
  `total_comments` int(10) unsigned NOT NULL default '0',
  `subscribed` enum('yes','no') NOT NULL default 'yes',
  `md5key` varchar(32) NOT NULL default '',
  `signup` varchar(14) NOT NULL default '',
  `timestamp` timestamp(14) NOT NULL,
  `is_approved` enum('0','1') NOT NULL default '1',
  `total_files` smallint(6) NOT NULL default '0',
  `last_logged` datetime NOT NULL default '-00-00 00:00:00',
  `city` varchar(32) NOT NULL default '0',
  `address` varchar(64) default NULL,
  `zip` varchar(32) default NULL,
  `talent` varchar(32) default NULL,
  `phone` varchar(32) default NULL,
  `height` varchar(10) default NULL,
  `weight` varchar(10) default NULL,
  `education` varchar(32) default NULL,
  `hobby` varchar(32) default NULL,
  `topregion` enum('enabled','disabled') NOT NULL default 'disabled',
  `top30` enum('enabled','disabled') NOT NULL default 'disabled',
  `top10` enum('enabled','disabled') NOT NULL default 'disabled',
  `top` enum('enabled','disabled') NOT NULL default 'disabled',
  `total_ratings` smallint(5) unsigned default '1',
  `total_points` mediumint(9) unsigned default '10',
  `average_rating` decimal(6,4) default '10.',
  `art` text,
  `language` text,
  `sport` text,
  `skill` text,
  `experience` text,
  `club` text,
  `lastname` varchar(250) default NULL,
  `secondid` varchar(32) default NULL,
  `chosens` enum('enabled','disabled') default 'disabled',
  `email_status` enum('enabled','disabled','queued','approved') NOT NULL
default 'enabled',
  `chosen` varchar(20) NOT NULL default 'enabled',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `md5key` (`md5key`),
  UNIQUE KEY `username_2` (`username`),
  UNIQUE KEY `email_2` (`email`),
  KEY `sex` (`user_type`),
  KEY `timestamp` (`timestamp`),
  KEY `signup` (`signup`),
  KEY `username` (`username`),
  KEY `email` (`email`),
  KEY `subscribed` (`subscribed`)
)

#
# Dumping data for table `users`
#

INSERT INTO `users` VALUES (1, 'username', 'password', 'firstname',
'lastname', '', 19, 11, 'City', 'Sweden.gif', '[EMAIL PROTECTED]',
'http://', '', 'here', '', 'jpg', 'approved', 0, 'yes',
'69f404925df883e0e5579d65b7768e7c', '20031007135005', 20031102044856, '1',
1, '2003-10-11 03:20:19', 'Stockholm', '', '', '', '', '176', '60', '2', '',
'disabled', 'disabled', 'disabled', 'disabled', 1717, 5410, '3.1508', NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'enabled', 'enabled', 'enabled');




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Getting Fields from a sql table

2002-10-07 Thread Soheil Shaghaghi

Hello everyone,
Can someone please tell me how I can do the following:
From the query below, I want to get the details of the header of the message
and display them on a page, one per line.
If I just query the Header field, it displays them in one long line.
What can I do to display the them one per filed?
sub _converttoHTML {
my $self = shift;
my $string   = shift;

$string =~ s/([^\s\]+\@[^\s\r\,\;\]+)/\%lta
href\=\$self-{_ScriptUrl}?action=mailtoemail=$1\\%gt$1\%lt\/a\%gt/g;

$string =~ s/\/\amp\;/g;
$string =~ s/\/\lt\;/g;
$string =~ s/\/\gt\;/g;

$string =~ s/\%lt/\/g;
$string =~ s/\%gt/\/g;

return $string;
}

This is the code where the haeder gets displayed:
$self-_converttoHTML($self-{_Header}



my $query = SELECT
EmailID,Header,ToWho,FromWho,EmailFrom,FormattedDate,Subject,Content_Type,Si
zeOf,;
$query
.=Location,NumOfAttachments,Notes,CC,Unread,BCC,SaveCopy,SendHTML,Priority,
Signature FROM EMAILS WHERE ;
$query .=EmailID = $EmailID AND UserID = $UserID;
my $sdb = $self-{_dbobj}-prepare($query);
$sdb-execute;


while(my($EmailID,$Header,$ToWho,$FromWho,$EmailFrom,$FormattedDate,$Subject
,$Content_Type,$SizeOf,$Location,$NumOfAttachments,$Notes,$CC,$Unread,$BCC,$
SaveCopy,$SendHTML,$Priority,$Signature)=$sdb-fetchrow_array) {
$self-{_EmailID}   = $EmailID;
$self-{_Header}= $Header;
$self-{_ToWho} = $ToWho;
$self-{_FromWho}   = $FromWho;
$self-{_EmailFrom} = $EmailFrom;
$self-{_FormattedDate} = $FormattedDate;
$self-{_Subject}   = $Subject;
$self-{_SizeOf}= $SizeOf;
$self-{_Location}  = $Location;
$self-{_NumOfAttachments}  = $NumOfAttachments;
$self-{_Notes} = $Notes;
$self-{_Content_Type}  = $Content_Type;
$self-{_CC}= $CC;
$self-{_BCC}   = $BCC;
$self-{_SaveCopy}  = $SaveCopy;
$self-{_SendHTML}  = $SendHTML;
$self-{_Unread}= $Unread;
$self-{_Signature} = $Signature;
$self-{_Priority}  = $Priority;
last;
}


The header should look like this:

Return-Path: [EMAIL PROTECTED]
Received: from site.com (ns1.site.net [216.188.0.66])
by www.site.com (8.11.1/8.11.1) with ESMTP id g8I2Eir74182
for [EMAIL PROTECTED]; Tue, 17 Sep 2002 19:14:44 -0700 (PDT)
(envelope-from [EMAIL PROTECTED])
Received: from servername (adsl-63-207-125-101.dsl.sndg02.pacbell.net
[63.207.125.101])
by site.com (8.9.3/8.9.3) with SMTP id TAA30428
for [EMAIL PROTECTED]; Tue, 17 Sep 2002 19:21:36 -0700
Reply-To: [EMAIL PROTECTED]
From: Sender Name [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: test
Date: Tue, 17 Sep 2002 19:16:56 -0700
Message-ID: [EMAIL PROTECTED]
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary==_NextPart_000_55F6_01C25E7E.C991C8E0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Importance: Normal
X-UIDL: =hN!(@!!Sa]!Ig~!


But it looks like this:
Return-Path: [EMAIL PROTECTED] Received: from site.com (ns1.site.net
[216.188.0.66]) by www.site.com (8.11.1/8.11.1) with  SMTP id g8I2Eir74182
for [EMAIL PROTECTED]; Tue, 17 Sep 2002 19:14:44 -0700 (PDT)
(envelope-from [EMAIL PROTECTED]) Received: from servername
(adsl-63-207-125-101.dsl.sndg02.pacbell.net [63.207.125.101]) by site.com
(8.9.3/8.9.3) with SMTP id TAA30428 for [EMAIL PROTECTED]; Tue, 17 Sep 2002
19:21:36 -0700 Reply-To: [EMAIL PROTECTED] From: Sender Name
[EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: test Date: Tue, 17 Sep
2002 19:16:56 -0700 Message-ID:
[EMAIL PROTECTED] MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary==_NextPart_000_55F6_01C25E7E.C991C8E0 X-Priority: 3 (Normal)
X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416
(9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Importance: Normal X-UIDL: =hN!(@!!Sa]!Ig~!



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Moving Mysql

2002-09-12 Thread Soheil Shaghaghi

Hello everyone,
I have my MySQL database n the var partition of a FreeBSD server.
The problem is that the partition is almost full, and now I can't start the
SQL server!

I am thinking of moving the MySQL data directory to another partition, but I
don't know how I should do this.
Can anyone please tell me how, and also do I have to change any settings
after moving the data directory?

Thanks so much.



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




limiting the user

2002-08-31 Thread Soheil Shaghaghi

Hi everyone,
I am running a FreeBSD server with MySQL 3.23
I want to let my virtual users create/drop tables and limit the size of each
table, and also the number of tables they can create.

Can someone please tell me how I can do this?
Is it possible wit applications such as webmin, or phpMyAdmin?

Thanks so much



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




limiting the user

2002-08-29 Thread Soheil Shaghaghi

Hi everyone,
I am running a FreeBSD server with MySQL 3.23
I want to let my virtual users create/drop tables and limit the size of each
table, and also the number of tables they can create.

Can someone please tell me how I can do this?
Is it possible wit applications such as webmin, or phpMyAdmin?

Thanks so much



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




What's wrong with this code?

2002-08-26 Thread Soheil Shaghaghi

Hi everyone,
In the following code:

sub DATEJOINED{
my %arg = @_;
if (! $arg{USER}) {return undef}
return $arg{USER}-get(field='RegistrationDate');
}
The field Registration date is returned from the mysql table for the user
who is currently logged in in the following format:
Thu, Mar 1st, 2001

What I would like to do is change this date to the raw format (i.e.
20010801)

Can anyone please tell me how I can do this?
I tried the following, but get a bunch of errors!

sub DATEJOINEDRAW {
my %arg = @_;
if (! $arg{USER}) {return undef}
return $arg{USER}-get(field='DATE_FORMAT(RegistrationDate,
'%M %e, %Y')');

Thanks so much.



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




mySQL Language

2002-06-02 Thread Soheil Shaghaghi

Hello everyone.
I am trying to add non-Latin text to MySQL. Specifically speaking I need to
use Persian fonts.
I can add the text in the sql tables with no problem. I can also display
them on the generated cgi pages which call those tables. The problem I have
is when I go back to edit these tables, I see entries similar to this:

aaUUEaAaUYiDIaUCa

Here is when the problem starts. If I try to edit the text, and save it, it
saves them in an unreadable format, and therefore displays them as such.
Can anyone tell me what I might do to get around this issue?

Thanks so much,
Soheil


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Delete Problem

2002-05-28 Thread Soheil Shaghaghi

Hello everyone.
I have an issue that can't figure out, and was wondering if someone can help
me with it.
I offer mySQL based e-mail account to my users.
The actual e-mails are stored in a text based directory.
Sometimes when the e-mail is put in the trashcan, it actually deletes the
e-mail folder, so when the user goes to clear the trash, it doesn't find the
referred folder/file, and gives ISE.
Looking at the below subroutine, can anyone please tell me what I can do to
fix this?

I basically want to check for the e-mail directory or the file, and if it
doesn't exist, simply ignore it, and delete the ID from the database.

Thanks so much

sub deleteemails {
my $self = shift;
my $emails   = shift;

my $whereE = undef;
my $whereA = undef;
#   print Content-Type: Text/Html\n\n;
foreach my $id (@$emails) {
if ((! $id) || ($id =~ /\D/)) {next;}
my $qid = $self-{_dbobj}-quote($id);

if ($self-{_StoragePath} !~ /\w/) { die(StoragePath does not contain 
a
useful value) }
#deletes all files in EmailID Directory (Email.txt and all attachment
files)
my $EmailDir = $self-{_StoragePath}/$self-{_UserID}/$id;
if (! -d $EmailDir) { die($EmailDir is not a directory); return}
opendir (EMAIL, $EmailDir) or die(Can't open directory $EmailDir 
$!),
return;
while(my $files = readdir(EMAIL)) {
if ($files =~ /\w/) {
if (! -e $EmailDir/$files) { die($EmailDir/$files 
does not exist) }
unlink $EmailDir/$files or die(Can't delete file: 
$EmailDir/$files
$!);
$whereE .= EmailID = $qid OR ;
}
}
closedir(EMAIL);
rmdir($EmailDir) or die(Can't delete directory: $EmailDir $!);
}

$whereE =~ s/ OR $//;

if ($whereE){
my $UserID = $self-{_dbobj}-quote($self-{_UserID});
my $query = DELETE FROM EMAILS WHERE $whereE AND UserID = $UserID;
my $sdb = $self-{_dbobj}-prepare($query);
$sdb-execute;

$query = DELETE FROM ATTACHMENTS WHERE $whereE;
$sdb = $self-{_dbobj}-prepare($query);
$sdb-execute;
}
}


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: store JPG in MySQL DB

2002-05-20 Thread Soheil Shaghaghi

Hello everyone.
While you are on this subject, can I ask you a question?
Is it possible to store sound, or video in the mySQL database? If so, is it
wise? Are there any performance issues I should be aware of
I just want my users to be able to add their photo, and sound (or maybe a
short video) to their profile.

Thanks so much,
Soheil


-Original Message-
From: Sherzod B. Ruzmetov [mailto:[EMAIL PROTECTED]]
Sent: Mon, May 20, 2002 8:37 AM
To: Andrei Cojocaru
Cc: Sameer Maggon; [EMAIL PROTECTED]
Subject: Re: store JPG in MySQL DB



Hi Andrei

 If I were you I would not store a binary file into the database, I'd store
 the information required to fetch it from somewhere else like the mySQL
 manual suggests

But what difference does it make? Besides, I found storing it in the DB
more convenient than in the file system. In that case, you will have to
keep track ofboh the files in the file system, and their meta data in the
mysql tables.

Please advise



 
 Andrei Cojocaru
 [EMAIL PROTECTED]
 - Original Message -
 From: Sherzod B. Ruzmetov [EMAIL PROTECTED]
 To: Sameer Maggon [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Monday, May 20, 2002 12:26 AM
 Subject: Re: store JPG in MySQL DB


 
  For real-life example, check out http://cdbaza.ultracgis.com, and check
  out the filename
  of the thumbnails images. I'm SELECTing those images from the MySQL
  database.
 
  That's how it's done:
 
  1_ Create a table to store your JPGs, and the column that holds JPG data
 should be declared as BLOB
 
  CREATE TABLE images (
  image_id INT UNSIGNED NOT NULL AUT_INCREMENT PRIMARY KEY,
  image BLOB NOT NULL
  );
 
 
   2_ Now you are ready to load the JPG data into the image column.
  I use Perl to open the JPG file and dump the contents into the
table,
  and the resulting query looks something like:
 
  INSERT INTO images SET image=here goes contents of the JPG file;
 
  Perl code that does this job would look like:
 
  local ($/);
  sysopen (JPG, test.jpg, O_RDONLY) or die $!;
  $dbh-do(qq|INSERT INTO images SET image=?|, undef, JPG);
  close (JPG);
 
  Sorry if you don't know Perl, but you should be able to do similar
  thing in any other language you might be using
 
 
 
  Good luck!
 
  --
  Sherzod
 
 
 
 
  -
  Before posting, please check:
 http://www.mysql.com/manual.php   (the manual)
 http://lists.mysql.com/   (the list archive)
 
  To request this thread, e-mail [EMAIL PROTECTED]
  To unsubscribe, e-mail
 [EMAIL PROTECTED]
  Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
 
 




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RAND and MySQL version!

2002-05-14 Thread Soheil Shaghaghi

Hello All,
I am running 2 MySQL servers, one on Linux, and the other on FreeBSD.
Linux, MySQL version: 3.23.49
FreeBSD, MySQL version: 3.22.32

Problem:

The following code runs on the newer version of MySQL, and Linux, but when I
run it on the other server, I get sql error.

SELECT ID,Headlines,IsActive FROM DATABASE WHERE IsActive=1 ORDER BY RAND()
LIMIT 1

Can anyone please tell me if it's the version of MySQL causing this problem
or something else?

Is there anyway to get around this, without upgrading MySQL?

Thanks so much,
Soheil


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Birthday select

2002-04-19 Thread Soheil Shaghaghi

Hi everyone.
I have a sql database of users with their birth date (Y/M/D).

Can anyone please tell me how I can check whose birthday each day is, and
pull them from the database?

Thanks,
Soheil




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Optimizing the table

2002-04-19 Thread Soheil Shaghaghi

Hi all,
A few days ego, I asked the group about the meaning of the Overhead in sql.
Some
people were nice enough to answer me, and told me I needed to optimize the
table.

Here is what phpMyAdmin reports on the table:
Space usage : Type Usage
Data 1,602 KB
Index 3,729 KB
Overhead 24,718 Bytes
Effective 5,307 KB
Total 5,331 KB

Now, when I try to optimize the table, OPTIMIZE TABLE USERS; I get this
error:
error: The handler for the table doesn't support check/repair

Does anyone know what the problem is here?
Thanks again.






-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Error in the log files

2002-04-12 Thread Soheil Shaghaghi

Hi all,

I recently upgraded to Perl 5.6.1 and ever since I keep getting these errors
in my log files on my Linux machine every time the pages that get the data
from mysql are accessed:

Argument O_RDONLY isn't numeric in subroutine entry at
/usr/local/lib/perl5/5.6.1/i686-linux/DB_File.pm line 252.

can anyone please tell me what they are and how I can fix them?

Thanks so much,
Soheil


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: RE: Help with Tables Please

2002-04-08 Thread Soheil Shaghaghi

Thanks, It worked :)
It was my mistake!

Thanks again,
Soheil



Soheil,
Monday, April 08, 2002, 7:09:44 AM, you wrote:

SS Thanks for the tip Dan,
SS I changed it, but it still gives me the same error.
SS Any other suggestion?

hm ... I have tested your example and it worked fine ...

What version of MySQL server do you use and how did you changed column
type?

SS In the last episode (Apr 07), Soheil Shaghaghi said:
 Hi all, I have create the following mysql table, and when I try to
 add more than 128 rows in the table, I get this error: Duplicate
 entry '127' for key 1 I have no duplicate entries in there, and I
 can not figure out what's going on!

 CREATE TABLE CMSHOWNREQUIREDFIELDS1 (
   FieldID tinyint(4) DEFAULT '0' NOT NULL,
   PRIMARY KEY (FieldID)
 );
SS This is a FAQ.  TINYINT has a range of -127 to 127.  Change it to INT.





--
For technical support contracts, goto https://order.mysql.com/
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   ___/   www.mysql.com




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Help with Tables Please

2002-04-07 Thread Soheil Shaghaghi

Hi all,
I have create the following mysql table, and when I try to add more than 128
rows in the table, I get this error:
Duplicate entry '127' for key 1
I have no duplicate entries in there, and I can not figure out what's going
on!

CREATE TABLE CMSHOWNREQUIREDFIELDS1 (
  FieldID tinyint(4) DEFAULT '0' NOT NULL,
  FieldName tinytext NOT NULL,
  ShownRegistration tinyint(3) unsigned DEFAULT '0' NOT NULL,
  Required tinyint(4) DEFAULT '0' NOT NULL,
  DisplayName tinytext NOT NULL,
  DisplayNameFarsi tinytext NOT NULL,
  ModifyFlag tinyint(3) unsigned DEFAULT '1' NOT NULL,
  ShownProfile tinyint(3) unsigned DEFAULT '0' NOT NULL,
  ProfileRequired tinyint(4) DEFAULT '0' NOT NULL,
  ShownUpgradeAccount tinyint(3) unsigned DEFAULT '0' NOT NULL,
  UpgradeRequired tinyint(4) DEFAULT '0' NOT NULL,
  ShownMakeDonation tinyint(3) unsigned DEFAULT '0' NOT NULL,
  DonationRequired tinyint(4) DEFAULT '0' NOT NULL,
  FTPAllowed tinyint(3) unsigned,
  Price tinytext,
  PRIMARY KEY (FieldID)
);

Thanks


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Help with Tables Please

2002-04-07 Thread Soheil Shaghaghi

Thanks for the tip Dan,
I changed it, but it still gives me the same error.
Any other suggestion?


-Original Message-
From: Dan Nelson [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 07, 2002 7:08 PM
To: Soheil Shaghaghi
Cc: [EMAIL PROTECTED]
Subject: Re: Help with Tables Please


In the last episode (Apr 07), Soheil Shaghaghi said:
 Hi all, I have create the following mysql table, and when I try to
 add more than 128 rows in the table, I get this error: Duplicate
 entry '127' for key 1 I have no duplicate entries in there, and I
 can not figure out what's going on!

 CREATE TABLE CMSHOWNREQUIREDFIELDS1 (
   FieldID tinyint(4) DEFAULT '0' NOT NULL,
   PRIMARY KEY (FieldID)
 );


This is a FAQ.  TINYINT has a range of -127 to 127.  Change it to INT.

--
Dan Nelson
[EMAIL PROTECTED]

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: backup databases

2002-04-03 Thread Soheil Shaghaghi

You can try something like this:
DateDir=Directory where you want your backups saved
print $output-printheader;

my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst )=
localtime(time);
$year = $year + 1900;
$mon++;
my $filename = DataDir/MySQLBackup$mon-$mday-$year.sql;
my $c = ;
my $oldfilename = $filename.gz$c;
while (-e $oldfilename) {
$c++;
$oldfilename = $filename.gz$c;
}
if ($c  0) {
rename($filename.gz, $oldfilename);
}
my $command = undef;
$command = mysqldump -u DatabaseUserName -p DatabasePassWord
DatabaseName$filename;
my $result = `$command`;
system(gzip -9 $filename);

print 'BODY BGCOLOR=#FFCC99 text=black link=black 
alink=#C0C0C0
vlink=black' . \n\n;
print CENTER\n;
print TABLE BGCOLOR=#7373AA BORDER=0 WIDTH=90%TR 
BGCOLOR=#7373AATD
BGCOLOR=#7373AA\n;
print TABLE BGCOLOR=#7373AA BORDER=0 CELLPADDING=1 CELLSPACING=1
WIDTH=100%\n;
print TR BGCOLOR=#7373AATD BGCOLOR=#7373AACENTERFONT
COLOR=whiteBBackup Performed/B/FONT/CENTER/TD/TR\n;
print TR BGCOLOR=white\n;
print TD BGCOLOR=white\n;
print BYour data has been backed up and stored in your Data 
directory
($filename.gz).\n;
print /TD\n;
print /TR\n;
print /TABLE\n;
print /TD/TR/TABLE\n;
$output-done;




-Original Message-
From: Eberhard W Lisse [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 03, 2002 3:07 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: backup databases


 From: David McInnis [EMAIL PROTECTED]

 Could you share your script for doing the date thing with the rest of
 us?  That sounds useful.

Isn't there a perl script around for backuping?

Something like:

mysqldump DB --add-drop-table --opt \
|gzip  DBdump.`date +%Y-%m-%d`.gz

should even sort right.

el

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Help with mysql and cgi

2002-04-02 Thread Soheil Shaghaghi

Hi all,
I hope I am not too far off the topic here. I actually need help with cgi,
and mysql.
Please refer to the this file to see the program itself:
http://www.jhanna.com/ExtraPage4.txt

What I need to do is to break apart the subroutine, and do some
manupulations on it before displaying the output and I just can't figure out
how to do it!

I basically want to accumplish 4 different tasks:
1. If an flag is set in the table to show the contact person, then I want
this line displayed:

If (IsContact=1) then show:
TR VALIGN=TOPTD
Document Published by: $Announcement{'Contact'}, whose email address is:
$Announcement{'ContactEmail'}
/TD/TR
Else, I don't want it there.


2.
TR VALIGN=TOPTD
BFONT FACE=$PRO::config-{COLORS_ALL_FontFace}
COLOR=$PRO::config-{COLORS_ALL_TitleColor}
SIZE=$PRO::config-{COLORS_ALL_FontSizeSmall}
$Announcement{'RelatedTitle'}/FONT/BBR
A
HREF=\$Announcement{'RelatedURL1'}\$Announcement{'RelatedText1'}/ABR
A
HREF=\$Announcement{'RelatedURL2'}\$Announcement{'RelatedText2'}/ABR
A
HREF=\$Announcement{'RelatedURL3'}\$Announcement{'RelatedText3'}/ABR
A
HREF=\$Announcement{'RelatedURL4'}\$Announcement{'RelatedText4'}/ABR
A
HREF=\$Announcement{'RelatedURL5'}\$Announcement{'RelatedText5'}/ABR
A HREF=\$Announcement{'RelatedURL6'}\$Announcement{'RelatedText6'}/A
/TD/TR

What I want to do here is to check for validity of the field
$Announcement{'RelatedTitle'}, and if this field is not empty, then outout a
list of the URL's and the Names in a row, and numbered from 1 to...
A HREF=\$Announcement{'RelatedURLX'}\$Announcement{'RelatedTextX'}/A


3. If the option is set in the configuration files, the I want to be able to
either disply/not display the following line:
A HREF=\$PRO::config-{'Urls_emailit.cgi'}\img border=0
src=$PRO::config-{ILP_All_RequestInfo_Icon}
alt='$PRO::config-{ILP_All_RequestInfoAlt}'/A

4.
The line:
img border=0 src=$Announcement{'ThirdIcon'}
width=$Announcement{'ThirdWidth'} height=$Announcement{'ThirdHeight'}
alt=$Announcement{'ThirdAltText'}
I want to check the table first, and if there exists a
$Announcement{'ThirdIcon'}, then display this line. I know if the values are
not there, it doesn't display them automaticaly, but the problem is that if
that's the case, I get a lits of empty spaces in the page, and if I can do
some checking, I can eliminate those spaces.

P.S. I am willing to pay someone to advice me on how to do this

Thanks so much,
Soheil


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Updating 2 tables using flags

2002-03-31 Thread Soheil Shaghaghi

Hello everyone,
I have 2 MySQL tables called ANNOUNCEMENT1, and ANNOUNCEMENT2
CREATE TABLE ANNOUNCEMENT1(
  AnnouncementID bigint(20) unsigned DEFAULT '0' NOT NULL,
  Title varchar(250),
  DatePosted date DEFAULT '-00-00' NOT NULL,
  Content text,
  ArchiveDate date,
  DateShown date DEFAULT '-00-00' NOT NULL,
  IsArchived tinyint(3) unsigned DEFAULT '0' NOT NULL,
  IsFeatured tinyint(3) unsigned DEFAULT '0' NOT NULL,
  FeaturedDate date,
  IsActive tinyint(3) unsigned DEFAULT '0' NOT NULL,
  Hits bigint(20) unsigned DEFAULT '0' NOT NULL,
  Votes bigint(20) unsigned DEFAULT '0' NOT NULL,
  KEY AnnouncementID (AnnouncementID),
  KEY ID (AnnouncementID)
);
CREATE TABLE ANNOUNCEMENT2(
  AnnouncementID bigint(20) unsigned DEFAULT '0' NOT NULL,
  Title varchar(250),
  DatePosted date DEFAULT '-00-00' NOT NULL,
  Content text,
  ArchiveDate date,
  DateShown date DEFAULT '-00-00' NOT NULL,
  IsArchived tinyint(3) unsigned DEFAULT '0' NOT NULL,
  IsFeatured tinyint(3) unsigned DEFAULT '0' NOT NULL,
  FeaturedDate date,
  IsActive tinyint(3) unsigned DEFAULT '0' NOT NULL,
  Hits bigint(20) unsigned DEFAULT '0' NOT NULL,
  Votes bigint(20) unsigned DEFAULT '0' NOT NULL,
  TrueFlag tinyint(3) unsigned DEFAULT '0' NOT NULL,
  KEY AnnouncementID (AnnouncementID),
  KEY ID (AnnouncementID)
);

Here is what I want to do:
1. Create announcements in ANNOUNCEMENT1 table:
WHat I do is basically create the announcement, and when I go to save it, I
save it to both tables with the same ID number (The ID numbers are generated
on the fly)

2. At this point, I can go and edit each table by itself. If I never edit
ANNOUNCEMENT2, TrueFlag is by default=0
However, if I do edit it, the program automatically sets to 1.

2. Next, I want to be able to edit these 2 tables depending on the flag
(TrueFlag)

A. If I go to edit ANNOUNCEMENT1, I want to look at the TrueFlag in
ANNOUNCEMENT2. If TrueFlag=0, the UPDATE overrights both tables.
If TrueFlag=1, then I just want to overright some of the fields and not all
of them.
For example, when updating ANNOUNCEMENT1, I want to update the following
fields in ANNOUNCEMENT2:
  DatePosted
  ArchiveDate
  DateShown
  IsArchived
  IsFeatured
  FeaturedDate

and leave the rest as there were!

Any ideas?

Thanks so much,
Soheil




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Installing MySQL libraries on Linux

2002-03-29 Thread Soheil Shaghaghi

Hi,
I wonder if this is the place to ask this question or not!
I have been trying to install DBD::mysql, or any other mysql, or DBD modules
from CPAN on my Linux, and FreeBSD servers.
I just can't get them to install.

The first error that appears is :
Can't exec mysql_config: No such file or directory at Makefile.PL line 16
And then:
Note (probably harmless): No library found for -lgz
Warning: duplicate function definition 'rows' detected in mysql.xs, line 289

Running make test
PERL_DL_NONLAZY=1
/usr/bin/perl -Iblib/arch -Iblib/lib -I/usr/local/lib/perl5/5.6.1/i686-linux
 -I/usr/local/lib/perl5/5.6.1 -e 'use Test::Harness qw(runtests $verbose);
$verbose=0; runtests @ARGV;' t/*.t
t/00base...install_driver(mysql) failed: Can't load
'blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql:
blib/arch/auto/DBD/mysql/mysql.so: undefined symbol:
mysql_real_escape_string at
/usr/local/lib/perl5/5.6.1/i686-linux/DynaLoader.pm line 206.
 at (eval 1) line 3
Compilation failed in require at (eval 1) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at t/00base.t line 38

Followed by bunch of other errors!

Can anyone help me figure this out please?

Thank so much,
Soheil


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Fetching Data based on the day

2002-03-27 Thread Soheil Shaghaghi

Hello everyone.
I am trying to extract the data from MySQL based on the month, and day of
the item, and post them on a page.
Something similar to Today in History
Here is a partial list of my table:
CREATE TABLE ANNOUNCEMENT (
  AnnouncementID bigint(20) unsigned DEFAULT '0' NOT NULL,
  Title varchar(250),
  DateShown date DEFAULT '-00-00' NOT NULL
  KEY AnnouncementID (AnnouncementID),
  KEY ID (AnnouncementID)
);
Can anyone please tell me what I need to do?
Here is what I have so far:
SELECT AnnouncementID,Title,DateShown FROM ANNOUNCEMENT WHERE
DateShown=NOW() ORDER BY DateShown DESC

The problem is that it matches the list to the entire date (including the
year), but I only want to look at the month, and the day, when fetching the
data.

Thanks so much.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php