Re: [PHP-DB] Problems with mysql_num-rows()

2004-10-31 Thread Doug Thompson
The variables are not being expanded. As a minimum, you need to escape the single quotes.
 $query = "SELECT * from user where name=\'$userid\' and 
pass=password(\'$password\')"

Alternatively, you can concatenate the expanded variables.
 $query = "SELECT * from user where name='".$userid."' and 
pass=password('".$password."')"

Good luck,
Doug
Arne Essa Madsen wrote:
I have the following problem:
This one does not work:
 $query = "SELECT * from user where name='$userid' and 
pass=password('$password')";
  $result = mysql_query($query, $link);
  $num_rows = mysql_num_rows($result);

I get this error message:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result 
resource in c:\wamp\www\fs1812_new\authmain.php on line 18

This one works OK:
  $query = "SELECT * FROM user";
  $result = mysql_query($query, $link);
  $num_rows = mysql_num_rows($result);
What is wrong and how can I use mysql_num_rows when the query include 
"WHERE"

A fast response will be very much appreciated.
Arne Essa Madsen;
[EMAIL PROTECTED] 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Problems with mysql_num-rows()

2004-10-31 Thread Bastien Koert
Very simply, either your connection is messed up, you are not getting a 
result set back or there is an error in your sql

try this:
$result = mysql_query($query, $link) or die ("failed because 
".mysql_error());

then start debugging
bastien


From: "Arne Essa Madsen" <[EMAIL PROTECTED]>
Reply-To: "Arne Essa Madsen" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Problems with mysql_num-rows()
Date: Sun, 31 Oct 2004 19:32:09 +0100
I have the following problem:
This one does not work:
 $query = "SELECT * from user where name='$userid' and
pass=password('$password')";
  $result = mysql_query($query, $link);
  $num_rows = mysql_num_rows($result);
I get this error message:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in c:\wamp\www\fs1812_new\authmain.php on line 18
This one works OK:
  $query = "SELECT * FROM user";
  $result = mysql_query($query, $link);
  $num_rows = mysql_num_rows($result);
What is wrong and how can I use mysql_num_rows when the query include
"WHERE"
A fast response will be very much appreciated.
Arne Essa Madsen;
[EMAIL PROTECTED]
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Something wierd with time() and curdate()

2004-10-31 Thread Jason Wong
On Sunday 31 October 2004 22:45, Bobo Wieland wrote:
> There is something wierd going on over here...
>
> I have a date field, datum, in mysql that I cast to a timestamp and check
> against time(). If the datum value is more than one day old the table finds
> a new random row and sets the datum field to CURDATE(). Now, this has
> worked for two years now, but today the script suddenly finds a new random
> row each time the script is run... 

Would this line have anything to with it? If not, post some concise code (see 
below).

> mysql_data_seek($result, rand(0,$rows));


> I've notice this just after 11 pm today. 
> As I can see from some debugging time() allways returns a higher value than
> the timestamp + 86400... Have I missed something in this script for the
> last couple of years or is there a bug somewhere? Could it have something
> to do with the fact that we turned the time back one hour last night?
>
> This is the code btw:

Please *try* to isolate the problem and post CONCISE code which sufficiently 
illustrates your problem. For example (for this particular problem) if you 
suspect PHP is calculating the dates incorrectly then a few lines of code 
showing the date calculations would be sufficient. If you suspect MySQL is 
the culprit then a single query would be sufficient.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
"There are things that are so serious that you can only joke about them"
- Heisenberg
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Problems with mysql_num-rows()

2004-10-31 Thread Jason Wong
On Sunday 31 October 2004 18:32, Arne Essa Madsen wrote:
> I have the following problem:
>
> This one does not work:
>  $query = "SELECT * from user where name='$userid' and
> pass=password('$password')";

print $query;

>   $result = mysql_query($query, $link);

Use mysql_error().

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
An honest tale speeds best being plainly told.
  -- William Shakespeare, "Henry VI"
nly
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Problems with mysql_num-rows()

2004-10-31 Thread Arne Essa Madsen
I have the following problem:

This one does not work:
 $query = "SELECT * from user where name='$userid' and 
pass=password('$password')";
  $result = mysql_query($query, $link);
  $num_rows = mysql_num_rows($result);

I get this error message:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result 
resource in c:\wamp\www\fs1812_new\authmain.php on line 18

This one works OK:
  $query = "SELECT * FROM user";
  $result = mysql_query($query, $link);
  $num_rows = mysql_num_rows($result);

What is wrong and how can I use mysql_num_rows when the query include 
"WHERE"

A fast response will be very much appreciated.

Arne Essa Madsen;
[EMAIL PROTECTED] 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] selective query?

2004-10-31 Thread Dan Bowkley
I'm tweaking my internet speed tester thingamabob
(http://www.dibcomputers.com/bandwidthmeter/index.php) and am rather
stumped.  Currently, I'm grouping together all results from each domain (all
results from, say, adelphia.net are averaged and displayed as one, etc) and
to that end I stopped displaying IP address results.  Is there a way I can
do a selective group?  For example, all results from 11.22.33.44 should be
averaged and grouped together, and all results from adelphia.net should be
averaged and grouped as well.

Here's the code I've got that displays all results:

echo "Average speeds of each domain tested:";
$mongo = @mysql_query ("SELECT
substring_index(name,'.',-2),ROUND(MIN(speed),1),ROUND(AVG(speed),1),ROUND(M
AX(speed),1) FROM `readings` WHERE name <> ip GROUP BY
substring_index(name,'.',-2) ORDER BY substring_index(name,'.',-2) ASC");
echo "DomainLowest SpeedAverage
SpeedHighest Speed\n";
while ($mongorow = mysql_fetch_array($mongo, MYSQL_NUM))
{
 if($bg=='#dd') $bg='#ff' ;
 else $bg='#dd' ;
 echo "http://www.$mongorow[0]\";
target=\"new\">$mongorow[0]$mongorow[1]$mongorow[2]$mongorow[3]\n";
}
echo "";


Any ideas?

TIA,
Dan

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Something wierd with time() and curdate()

2004-10-31 Thread Bobo Wieland
There is something wierd going on over here...

I have a date field, datum, in mysql that I cast to a timestamp and check against 
time().
If the datum value is more than one day old the table finds a new random row and sets 
the datum field to CURDATE().
Now, this has worked for two years now, but today the script suddenly finds a new 
random row each time the script is run...
I've notice this just after 11 pm today.
As I can see from some debugging time() allways returns a higher value than the 
timestamp + 86400...
Have I missed something in this script for the last couple of years or is there a bug 
somewhere? Could it have something to do with the fact that we turned the time back 
one hour last night?

This is the code btw:

function bibelvers($link_id, $color = "white") {
 $myBible = new Bible($link_id, "FB");
 $myBible->set_delimiters("span","p","bibelversnum","text");
 $vers_nr = "";
 $vers_txt = "";
 $reset = false;
 $q = "SELECT vers,textkod,UNIX_TIMESTAMP(datum) as datum FROM dagensvers WHERE visad 
= 'NU'";
 $result = mysql_query($q, $link_id);
 if (mysql_affected_rows($link_id) == 1) {
  $v = mysql_fetch_object($result);
  if (time() > ($v->datum + ONEDAY)) {
   mysql_free_result($result);
   $q = "SELECT vers,textkod FROM dagensvers WHERE visad = 'NEJ'";
   $result = mysql_query($q, $link_id);
   $rows = mysql_affected_rows($link_id)-1;
   if ($rows >= 0) {
mysql_data_seek($result, rand(0,$rows));
$v = mysql_fetch_object($result);
$q = "UPDATE dagensvers SET visad = 'JA' WHERE visad = 'NU'";
mysql_query($q, $link_id);
$q = "UPDATE dagensvers SET datum = CURDATE(), visad = 'NU' WHERE textkod = 
'".$v->textkod."'";
mysql_query($q, $link_id);
   }
   else { $reset = true; }   
  }
 }
 else { $reset = true; }
 if ($reset) {
  $q = "UPDATE dagensvers SET visad = 'NEJ' WHERE visad = 'JA'";
  mysql_query($q, $link_id);
  $q = "SELECT vers,textkod FROM dagensvers WHERE visad = 'NEJ'";
  $result = mysql_query($q, $link_id);
  $rows = mysql_affected_rows($link_id)-1;
  mysql_data_seek($result, rand(0,$rows));
  $v = mysql_fetch_object($result);
  $q = "UPDATE dagensvers SET visad = 'NEJ' WHERE visad = 'NU'";
  mysql_query($q, $link_id);
  $q = "UPDATE dagensvers SET datum = CURDATE(), visad = 'NU' WHERE textkod = 
'".$v->textkod."'";
  mysql_query($q, $link_id);
 }
 $vers_nr = $v->vers;
 $vers_txt = $v->textkod;
 $myBible->str_vers_format($vers_txt, false, false);
 $str = "\n".
  "\t DAGENS BIBELVERS | ".$vers_nr."\n".
  "\t\n".
  "\t\t".
  $vers_txt.
  "\t\t\n".
  "\t\n".
  "\n";
 return $str;
} 

RE: [PHP-DB] PHP & Javascript

2004-10-31 Thread Mulley, Nikhil
Actaully No , as Javascript has to run at Web Browser end and PHP has to run at Server 
Side , And more at matter javascript memory ( variable values ) cannot be shared with 
PHP memory ( variable values ) , If you want want to share the variable values or 
result values then you can do away with PHP-PEAR Extension JavaScript.



Nikhil.

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]
Sent: Sunday, October 31, 2004 6:35 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] PHP & Javascript


On Saturday 30 October 2004 12:33, balwantsingh wrote:

> can anybody guide me how to embed php script into javascript. 

You can't.

> actually i am 
> using a function in  javascript and want that when this fuctions is called
> than some values to be stored in php session so that the values can be
> displayed in next page.

You can pass values from client-side using Javascript either via the URL 
($_GET) or form ($_POST) or cookies ($_COOKIE).  You can't manipulate the 
session variables directly.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
Defeat is worse than death because you have to live with defeat.
  -- Bill Musselman
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php