RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-09 Thread Mats Remman

Look at this snippet :
 $word = current($wordsarray); 
 next($wordsarray);
 $sql=$sql.$word);

if you have 2 words the sql would extend to
word1)word2) .. this is invalid sql syntax.

Change the 
while ($i  count($wordsarray)) 
{ 
$word = current($wordsarray); 
next($wordsarray);
$sql=$sql.$word);
$i++; 
}
bit into something like this
$sep = ;
foreach( $wordsarray as $v ) {
$sql .= $sep. $word ;
$sep =  OR band LIKE ;
}
$sql .= );

Then retry the queries.

oh and yes, include the mysql_query() as Mark Gordon mentioned.


Mats Remman
PHP Developer/Mysql DBA
Coretrek, Norway
+47 51978597 / +47 916 23566

 

 -Original Message-
 From: Matthew Loff [mailto:[EMAIL PROTECTED]]
 Sent: Monday, July 09, 2001 2:20 AM
 To: 'Ben Bleything'; 'Mark Gordon'; [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Dynamic SQL + result resource error
 
 
 
 Ha ha... I should have meantioned Here's what it -should- be or
 something of the like. :)
 
 I suspect that was the only problem with his code, but perhaps there's
 something else there.
 
 
 -Original Message-
 From: Ben Bleything [mailto:[EMAIL PROTECTED]] 
 Sent: Sunday, July 08, 2001 8:13 PM
 To: 'Matthew Loff'; 'Mark Gordon'; [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Dynamic SQL + result resource error
 
 
 Guess I'm just a big dumbass then, aren't I =P
 
 Oops.
 
 I suppose that would cause it to fail then, wouldn't it?
 
 =  Ben
 
 -Original Message-
 From: Matthew Loff [mailto:[EMAIL PROTECTED]] 
 Sent: Sunday, July 08, 2001 5:10 PM
 To: 'Ben Bleything'; 'Mark Gordon'; [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Dynamic SQL + result resource error
 
 
 The code you're referencing is my modification of his original post. :)
 
 
 -Original Message-
 From: Ben Bleything [mailto:[EMAIL PROTECTED]] 
 Sent: Sunday, July 08, 2001 8:04 PM
 To: 'Matthew Loff'; 'Mark Gordon'; [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Dynamic SQL + result resource error
 
 
 Sure he is.  Right here:
 
 $queryResult = mysql_query($sql);
 
 what exact error is occurring?
 
 -Original Message-
 From: Matthew Loff [mailto:[EMAIL PROTECTED]] 
 Sent: Sunday, July 08, 2001 5:00 PM
 To: 'Mark Gordon'; [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Dynamic SQL + result resource error
 
 
 You aren't calling mysql_query() to execute the query.
 
 //$find is text box input
 $wordsarray = explode( ,$find); 
 $sql = SELECT bandname FROM bands WHERE (bandname
 LIKE ;
 $i = 0;
 while ($i  count($wordsarray)) 
 { 
 $word = current($wordsarray); 
 next($wordsarray);
 $sql=$sql.$word);
 $i++; 
 }
 print $sqlhr;
 
 $queryResult = mysql_query($sql);
 
 while ($myrow=mysql_fetch_row($queryResult))
 {
 print $myrow[0],p;
 }
 
 
 -Original Message-
 From: Mark Gordon [mailto:[EMAIL PROTECTED]] 
 Sent: Sunday, July 08, 2001 7:54 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Dynamic SQL + result resource error
 
 
 Why is this code generating an error when it outputs a
 valid SQL statement?  (there are no parse errors)
 
 //$find is text box input
 $wordsarray = explode( ,$find); 
 $sql = SELECT bandname FROM bands WHERE (bandname
 LIKE ;
 $i = 0;
 while ($i  count($wordsarray)) 
 { 
 $word = current($wordsarray); 
 next($wordsarray);
 $sql=$sql.$word);
 $i++; 
 }
 print $sqlhr;
 while ($myrow=mysql_fetch_row($sql))
 {
 print $myrow[0],p;
 }
 
 =
 Mark
 [EMAIL PROTECTED]
 
 __
 Do You Yahoo!?
 Get personalized email addresses from Yahoo! Mail
 http://personal.mail.yahoo.com/
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Newbie:Backend scripts

2001-07-06 Thread Mats Remman

windows 2000 has a command called 'at' .. which is somewhat like crontab.
and
there is no reason to run lynx and whatever. 
php for windows has an exe for a reason

'php.exe c:\path\to\phpfile.php'

schedule that every two hours.

Mats Remman
PHP Developer/Mysql DBA
Coretrek, Norway
+47 51978597 / +47 916 23566

 

 -Original Message-
 From: PHPFAN [mailto:[EMAIL PROTECTED]]
 Sent: Friday, July 06, 2001 4:53 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Newbie:Backend scripts
 
 
 Thank you very much for your help Beau!!!
 
 Sagil.
 
 
 Beau Lebens [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  // OK, i just checked and tested (jeez i'm a nice guy.. :P) and
  // dodgy Windoze
  // schedule doesn't allow you to do it by the hour, so if you
  // want it every 2
  // hours, you'll have to set one, daily at 2am, one daily at
  // 4am etc etc, all
  // doing the same thing.
 
 
  change this, under the Schedule Advanced settings for the scheduled
 event
  you can
 
  Repeat Task
 
  every x minutes/hours etc, so only need one scheduled event for 
 it all :)
 
  beau
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Authomatic Sorting

2001-07-04 Thread Mats Remman

The 'problem' here is the logic of sql databases.

you have one id and one 'username' and they belong to eachother.
id 1 - user 1
id n - user n

meaning if you delete user 23, only id 23 is affected. If you want the
userid 'resorted' you will have to issue a few commands (which also would
destroy the logic of having the id column at all)

alter table mytable drop idcolumn;
alter table mytable add idcolumn unsigned int not null auto_increment
[primary key];

add primary key if it is the primary key.

I would rather suggest you dropped the 001 002 003 column, and used php to
keep count.

example

user001
user002
user0..
user075 (lets say you have 65 users total and that somewhere in 30-50 you
have been deleting)

$res = mysql_query(select username from mytable);
$num = mysql_num_rows($res); // this would give 65

$i = 1;
while($row = mysql_fetch_row($res)) {
echo user id $i - username .$row[0]; $i++;
}

this would print a list from 001 - 065 with every username in it.

Mats Remman
PHP Developer/Mysql DBA
Coretrek, Norway
+47 51978597 / +47 916 23566



 -Original Message-
 From: Wilmar Pérez [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 04, 2001 10:50 PM
 To: PHP List
 Subject: [PHP-DB] Authomatic Sorting


 Hello guys

 I have the following two problems:

 I've got a table with an autoincrement field which is the registry's ID,
 everything goes well until I delete any registry.  MySQL doesn't re-sorts
 the information.  That is, I have the following:

 001  user1
 002  user2
 003  user3

 If I delete user2, I would like to have something as shown next:

 001  user1
 002  user3

 But instead I end up with the following:

 001  user1
 003  user3

 Any idea or comment?
 ---
 Wilmar Pérez
  IT Manager - Central Library
  University of Antioquia
Medellín - Colombia
   tel: ++57(4)2105145
 ---


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] sql problem

2001-06-26 Thread Mats Remman

@a is here an internal 'session' variable used in sql databases (atleast
mysql).

simple usage :

select @a:=1;
- 1

select @b:=10;
- 10

select @a + @b;
- 11

These variables are used to hold temporary numbers and characters, so the
interaction between the script language and the database can be held to a
minimum.

Mats Remman
PHP Developer, MySQL DBA
Coretrek, Norway
+47 51978591 / +47 91623566

 -Original Message-
 From: Fai [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 26, 2001 5:55 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] sql problem


 SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
 UPDATE table2 SET summmary=@A WHERE type=1;

 What does @A: mean?

 Thank you very much!



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Am I missing something important here ?

2001-05-24 Thread Mats Remman

Oh my.. seems i didnt see the reference of $queryresult. ignore my comment
:)

but the first mysql_query is useless.

;Mats



 -Original Message-
 From: Mats Remman [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 24, 2001 12:35 PM
 To: annabelle.imray; [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Am I missing something important here ?


 Your problem here is simply that the $queryresult gets lost in
 the function.
 It is never returned.

 change return true;
 into   return $queryresult;


 Mats Remman


  -Original Message-
  From: annabelle.imray [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, May 24, 2001 1:02 AM
  To: [EMAIL PROTECTED]
  Subject: [PHP-DB] Am I missing something important here ?
 
 
  I have been given an example of how to use php  mysql from a hosting
  company.  They have the following function:
 
  #
  function ExecuteQuery ($linkdb, $queryresult, $querytext) {
 
   $queryresult = mysql_query($querytext, $linkdb);
 
if (($queryresult != false) and (mysql_errno() == 0)) {
return true;
   } else {
return false;
   }
  }
  #
 
  And an example of it's usage:
 
 
  $query = SELECT * FROM test;
 
   if ($mysql_result = mysql_query($query, $linkdb)) {
if (ExecuteQuery($linkdb, $result, $query)) {
 while ($row = NextRow($result)) {
  print(''.$row[1].' : '.$row[2].'br');
 }
}
}
 
  Can anyone tell me why the first if exists in their usage
  example, e.g. if
  ($mysql_result = mysql_query($query, $linkdb)) {
 
  As the $mysql_result variable is not used after this statement
  and the query
  is performed again in the ExecuteQuery() function;
 
  As I have said, am I missing something important here?
 
  Thanks
 
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]