Re: [PHP] mysql problems [SOLVED]

2011-05-14 Thread Curtis Maurand


Sean Greenslade wrote:


 
 [MASSIVE
SNIP]
 
 Well, from what I saw while wading through your
code, you allow
 unsanitized
 variables to be
concatenated to your queries. Big no-no! For ANY

client-generated variable, always sanitize with
mysql_real_escape_string.
 In
 fact, sanitize all your
variables. It can't hurt.
 
 Also, please don't take a
request for your entire code too literally. We
 don't like to see
pages and pages and pages of code, just the pertinent
 bits.
 --
 --Zootboy
 
 Sent from my PC.
 
Thanks to all, but it was an infinite loop.  there was a
while ($_parent != 0) { } loop.  In the loop the database
is queried.  If the returned number of rows is greater than 0 then
perform then grab a $_parent from the database.  At some point, there
must be a parent that is = 0 and the loop breaks.  However, if the
page is called with category number that doesn't exist, then the if/then
clause is never true and $_parent never gets set to 0.  I simply
added and else clause.
while ($_parent != 0)
{
  if
($num_rows  0)
   {

perform some action
   }
   else
   {
 $_parent =
0;
   }
}

and that solved the
problem.

Thank you, everyone for your help.  

Curtis


RE: [PHP] mysql problems [SOLVED]

2011-05-14 Thread Jasper Mulder

[SNIP]
 added and else clause.
 while ($_parent != 0)
 {
   if
 ($num_rows  0)
{

 perform some action
}
else
{
  $_parent =
 0;
}
 }

 and that solved the
 problem.

 Thank you, everyone for your help.

 Curtis

A small remark:
I think it is good programming practice to place such static if-clauses before 
the while statement.
This prevents a lot of redundant checks and thus saves time.

Best regards,
Jasper
  
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] mysql problems

2011-05-12 Thread Tim Streater
On 11 May 2011 at 19:25, Curtis Maurand cur...@maurand.com wrote: 

 $_cartTotal=$0.00;

Surely that should be:

$_cartTotal = 0.00;


tim


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

Re: Re: [PHP] mysql problems

2011-05-12 Thread Curtis Maurand



Tim Streater wrote:
 On 11 May 2011 at 19:25, Curtis
Maurand cur...@maurand.com wrote:
 

$_cartTotal=$0.00;
 
 Surely that should
be:
 
 $_cartTotal = 0.00;

Good
pickup.  I missed that.  I didn't write the code, I'm just
trying to figure out what's going on.
 Thanks,  I'll look at
that.  --C


[PHP] mysql problems

2011-05-11 Thread Curtis Maurand


I'm running PHP 5.3.6, Mysql 5.1.51 and Apache 2.2.17

I have
code that does a simple mysql_query();  the query on the commandline
returns an empty set.  when run via PHP and the web server, the page
hangs, it never gets to the if (mysql_num_rows($result)  0) {}. and
the queries per second on mysql goes from roughly 4 per second to about
12,000.

Does anyone have any ideas?

Thanks,
Curtis


Re: [PHP] mysql problems

2011-05-11 Thread Marc Guay
 Does anyone have any ideas?

Sounds like it's getting caught in a loop.  Post the whole script for
best results.

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



Re: [PHP] mysql problems

2011-05-11 Thread Curtis Maurand


Marc Guay wrote:
 Does anyone have any ideas?
 
 Sounds like it's getting caught in a loop.  Post the whole script
for
 best results.
 
It looks like the site is
under attack, because I keep seeing the query, SELECT catagory_parent FROM 
t_catagories where catagory_ID= .
$_currentCat

where $_currentCat is equal to a
value not in the database.  The only way that this can happen is if
the page is called directly without going through the default page.


the script follows.  its called leftNav.php



?php
include
'media/includes/productDetail.php';

//$username =
alaric;
$username = pinetree;
//$password = password_removed;
$password =
password_removed;
$hostname = 127.0.0.1;
//$hostname = www.superseeds.com;

if($_SESSION[u_id]==){
$_SESSION[u_id] = uniqid();
}

//
$_cartTotal=$0.00;
$_cartCount=0;





function tallyCart($_u_id){
    global $username;
    global
$password;
    global $hostname; 
    global $_cartTotal; 
    global
$_cartCount; 
    
    $dbhandle =
mysql_connect($hostname, $username, $password) 
   
     or die(Unable to connect to
MySQL);
         
    $selected =
mysql_select_db(pinetree,$dbhandle) 
   
  or die(Could not select examples);
    
    //execute the SQL query and
return records
    $result = mysql_query(SELECT
* from tbl_Cart where u_ID='.$_u_id.');
    $_holder=;
    
    $_counter=0;
   
$_getSubTotal=0;
    $_showCheckOut=0;
    while ($row = mysql_fetch_array($result)) {
        $_showCheckOut=1;
        $_pdetail=new
ProductDetail($row{'product_ID'}, $row{'product_Quantity'}, $_u_id);
         $_getSubTotal +=
$_pdetail-_subTotal;
       
 $_counter++;
 }
   
$_cartTotal = $.number_format($_getSubTotal,2);
    $_cartCount = $_counter;
   
mysql_close($dbhandle);
}

tallyCart($_SESSION[u_id]);
?





div id=div_cartCall
    div id=div_cartCall_head
    You have ?php echo $_cartCount? items in your
cart.br/br/
    Cart total: ?php
echo $_cartTotal?
    /div
    div id=div_cartCall_foot
    a href=cart.php#65533; Go to
cart/a
    /div
/div
p





  ?php

//$username = alaric;
$username = pinetree;
//$password =
removed;
$password = removed;
//$hostname = 127.0.0.1;
$hostname =
www.superseeds.com;

$_parents = array();  
$counter=0;

if($_GET[cat]!=){
    $_parent =$_GET[cat];
}
else{
    $_parent =0;
}


$dbhandle2 = mysql_connect($hostname, $username, $password) 
 or die(Unable to connect to MySQL);
//echo
Connected to MySQLbr;

//select a database
to work with
$selected =
mysql_select_db(pinetree,$dbhandle2) 
  or
die(Could not select examples);

   
while ($_parent !=0) {
   
    $result_2 = mysql_query(SELECT catagory_parent
FROM t_catagories where catagory_ID= .$_parent);
        $num_rows_2 =
mysql_num_rows($result_2);
       
if($num_rows_2  0)
   
    {
       
    while ($row = mysql_fetch_array($result_2)) {
           
    $_parent= $row{'catagory_parent'};
           
    $_parents[$counter] = $row{'catagory_parent'};
           
    $counter++;
       
    }
        }
    }
    mysql_close($dbhandle2);
    



function getParent($catID,
$matchingID){

//$username = alaric;
$username
= pinetree;
//$password = removed;
$password = removed;
//$hostname =
127.0.0.1;
$hostname = www.superseeds.com;
    
    
   
$_parent=1;
    $_currentCat=$catID;
    $dbhandle2 = mysql_connect($hostname, $username,
$password) 
     or die(Unable to connect
to MySQL);
    //echo Connected to
MySQLbr;
    
   
//select a database to work with
    $selected =
mysql_select_db(pinetree,$dbhandle2) 
   
  or die(Could not select examples);
    
        while
($_parent !=0) {
       
    $result_2 = mysql_query(SELECT catagory_parent
FROM t_catagories where catagory_ID= . $_currentCat);
              while
($row = mysql_fetch_array($result_2)) {
   
           
$_parent=$row{'catagory_parent'};
   
           
if($row{'catagory_parent'}==$matchingID){
   
           
    mysql_close($dbhandle2);
   
           
 return true;
   
             }
   
 
}
        }
   
mysql_close($dbhandle2);
    return false;
    
}

?
  
  
  
  ?php






function getRowCount($_catID){

    global
$_parents;
    global $username;
    global $password;
    global
$hostname; 
     
   
$dbhandle = mysql_connect($hostname, $username, $password) 
     or die(Unable to connect to
MySQL);
     
   
$selected = mysql_select_db(pinetree,$dbhandle) 
      or die(Could not select
examples);
     
   
$result = mysql_query(SELECT COUNT(*) as theCount FROM t_catagories
where catagory_parent=.$_catID);
     
    while ($row = mysql_fetch_array($result)) {
       
if($row{'theCount'}==0){
   
        mysql_close($dbhandle);
            return
0;
        }
        else{
   
        mysql_close($dbhandle);
            return
.$row{'theCount'};
       
}
    }
}




function
generateNav($_parent, $_style){

   
if(getRowCount($_parent)0){
    
        global $_parents;
        global $username;
        global $password;
        global $hostname; 
         
   
    $dbhandle3 = 

Re: [PHP] mysql problems

2011-05-11 Thread Curtis Maurand


Marc Guay wrote:
 Does anyone have any ideas?
 
 Sounds like it's getting caught in a loop.  Post the whole script
for
 best results.
 
It looks like the site is
under attack, because I keep seeing the query, SELECT catagory_parent FROM 
t_catagories where catagory_ID= .
$_currentCat

where $_currentCat is equal to a
value not in the database.  The only way that this can happen is if
the page is called directly without going through the default page.


the script follows.  its called leftNav.php



?php
include
'media/includes/productDetail.php';

//$username =
alaric;
$username = pinetree;
//$password = password_removed;
$password =
password_removed;
$hostname = 127.0.0.1;
//$hostname = www.superseeds.com;

if($_SESSION[u_id]==){
$_SESSION[u_id] = uniqid();
}

//
$_cartTotal=$0.00;
$_cartCount=0;





function tallyCart($_u_id){
    global $username;
    global
$password;
    global $hostname; 
    global $_cartTotal; 
    global
$_cartCount; 
    
    $dbhandle =
mysql_connect($hostname, $username, $password) 
   
     or die(Unable to connect to
MySQL);
         
    $selected =
mysql_select_db(pinetree,$dbhandle) 
   
  or die(Could not select examples);
    
    //execute the SQL query and
return records
    $result = mysql_query(SELECT
* from tbl_Cart where u_ID='.$_u_id.');
    $_holder=;
    
    $_counter=0;
   
$_getSubTotal=0;
    $_showCheckOut=0;
    while ($row = mysql_fetch_array($result)) {
        $_showCheckOut=1;
        $_pdetail=new
ProductDetail($row{'product_ID'}, $row{'product_Quantity'}, $_u_id);
         $_getSubTotal +=
$_pdetail-_subTotal;
       
 $_counter++;
 }
   
$_cartTotal = $.number_format($_getSubTotal,2);
    $_cartCount = $_counter;
   
mysql_close($dbhandle);
}

tallyCart($_SESSION[u_id]);
?





div id=div_cartCall
    div id=div_cartCall_head
    You have ?php echo $_cartCount? items in your
cart.br/br/
    Cart total: ?php
echo $_cartTotal?
    /div
    div id=div_cartCall_foot
    a href=cart.php#65533; Go to
cart/a
    /div
/div
p





  ?php

//$username = alaric;
$username = pinetree;
//$password =
removed;
$password = removed;
//$hostname = 127.0.0.1;
$hostname =
www.superseeds.com;

$_parents = array();  
$counter=0;

if($_GET[cat]!=){
    $_parent =$_GET[cat];
}
else{
    $_parent =0;
}


$dbhandle2 = mysql_connect($hostname, $username, $password) 
 or die(Unable to connect to MySQL);
//echo
Connected to MySQLbr;

//select a database
to work with
$selected =
mysql_select_db(pinetree,$dbhandle2) 
  or
die(Could not select examples);

   
while ($_parent !=0) {
   
    $result_2 = mysql_query(SELECT catagory_parent
FROM t_catagories where catagory_ID= .$_parent);
        $num_rows_2 =
mysql_num_rows($result_2);
       
if($num_rows_2  0)
   
    {
       
    while ($row = mysql_fetch_array($result_2)) {
           
    $_parent= $row{'catagory_parent'};
           
    $_parents[$counter] = $row{'catagory_parent'};
           
    $counter++;
       
    }
        }
    }
    mysql_close($dbhandle2);
    



function getParent($catID,
$matchingID){

//$username = alaric;
$username
= pinetree;
//$password = removed;
$password = removed;
//$hostname =
127.0.0.1;
$hostname = www.superseeds.com;
    
    
   
$_parent=1;
    $_currentCat=$catID;
    $dbhandle2 = mysql_connect($hostname, $username,
$password) 
     or die(Unable to connect
to MySQL);
    //echo Connected to
MySQLbr;
    
   
//select a database to work with
    $selected =
mysql_select_db(pinetree,$dbhandle2) 
   
  or die(Could not select examples);
    
        while
($_parent !=0) {
       
    $result_2 = mysql_query(SELECT catagory_parent
FROM t_catagories where catagory_ID= . $_currentCat);
              while
($row = mysql_fetch_array($result_2)) {
   
           
$_parent=$row{'catagory_parent'};
   
           
if($row{'catagory_parent'}==$matchingID){
   
           
    mysql_close($dbhandle2);
   
           
 return true;
   
             }
   
 
}
        }
   
mysql_close($dbhandle2);
    return false;
    
}

?
  
  
  
  ?php






function getRowCount($_catID){

    global
$_parents;
    global $username;
    global $password;
    global
$hostname; 
     
   
$dbhandle = mysql_connect($hostname, $username, $password) 
     or die(Unable to connect to
MySQL);
     
   
$selected = mysql_select_db(pinetree,$dbhandle) 
      or die(Could not select
examples);
     
   
$result = mysql_query(SELECT COUNT(*) as theCount FROM t_catagories
where catagory_parent=.$_catID);
     
    while ($row = mysql_fetch_array($result)) {
       
if($row{'theCount'}==0){
   
        mysql_close($dbhandle);
            return
0;
        }
        else{
   
        mysql_close($dbhandle);
            return
.$row{'theCount'};
       
}
    }
}




function
generateNav($_parent, $_style){

   
if(getRowCount($_parent)0){
    
        global $_parents;
        global $username;
        global $password;
        global $hostname; 
         
   
    $dbhandle3 = 

Re: [PHP] mysql problems

2011-05-11 Thread Sean Greenslade
On Wed, May 11, 2011 at 2:25 PM, Curtis Maurand cur...@maurand.com wrote:



 Marc Guay wrote:
  Does anyone have any ideas?
 
  Sounds like it's getting caught in a loop.  Post the whole script
 for
  best results.
 
 It looks like the site is
 under attack, because I keep seeing the query, SELECT catagory_parent FROM
 t_catagories where catagory_ID= .
 $_currentCat

 where $_currentCat is equal to a
 value not in the database.  The only way that this can happen is if
 the page is called directly without going through the default page.


 the script follows.  its called leftNav.php


[MASSIVE SNIP]

Well, from what I saw while wading through your code, you allow unsanitized
variables to be concatenated to your queries. Big no-no! For ANY
client-generated variable, always sanitize with mysql_real_escape_string. In
fact, sanitize all your variables. It can't hurt.

Also, please don't take a request for your entire code too literally. We
don't like to see pages and pages and pages of code, just the pertinent
bits.
-- 
--Zootboy

Sent from my PC.


[PHP] mysql problems

2005-03-01 Thread Jed R. Brubaker
Hi all -

I could use a lead on a problem. I just don't know where to start.

I have a PHP script that populates a database table. No big deal. It creates 
mailing labels. However, a weird things keeps happening - every once in a 
while, a query is run twice. It is the same query, same information, even 
the same time (there is a now() in the query - and it is identical).

So the question is a simple one - is this a PHP problem or a MySQL problem? 
Or somewhere in the MySQL extension? And how would I know?

There is one clue to this otherwise vague problem. I believe that this 
predominantly happens when the database is under an above average load.

I would appreciate any help that I might be able to get.

Thank you.

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



Re: [PHP] mysql problems

2005-03-01 Thread Richard Lynch
Jed R. Brubaker wrote:
 I could use a lead on a problem. I just don't know where to start.

 I have a PHP script that populates a database table. No big deal. It
 creates
 mailing labels. However, a weird things keeps happening - every once in a
 while, a query is run twice. It is the same query, same information, even
 the same time (there is a now() in the query - and it is identical).

 So the question is a simple one - is this a PHP problem or a MySQL
 problem?
 Or somewhere in the MySQL extension? And how would I know?

 There is one clue to this otherwise vague problem. I believe that this
 predominantly happens when the database is under an above average load.

 I would appreciate any help that I might be able to get.

Possibly the users are clicking twice on Submit when the site is slow.

Try embedding an MD5 hash or some other random token in the FORM, and mark
them off as used when you INSERT a new row.  If a token is used just
ignore the insert.

Or, better yet, check that the values are the same and ignore it, and if
they are different, because the user used their Back button and
submitted new data, go ahead and INSERT.

It might *NOT* be users clicking too much, but that's USUALLY the cause,
and it's easy to detect and do the right thing once you embed something
in each FORM to uniquely identify it before they submit it back to you.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] mysql problems

2005-03-01 Thread Rory McKinley
Jed R. Brubaker wrote:
Hi all -
I could use a lead on a problem. I just don't know where to start.
I have a PHP script that populates a database table. No big deal. It creates 
mailing labels. However, a weird things keeps happening - every once in a 
while, a query is run twice. It is the same query, same information, even 
the same time (there is a now() in the query - and it is identical).

So the question is a simple one - is this a PHP problem or a MySQL problem? 
Or somewhere in the MySQL extension? And how would I know?

There is one clue to this otherwise vague problem. I believe that this 
predominantly happens when the database is under an above average load.

I would appreciate any help that I might be able to get.
Thank you.
Hi Jed
Can you post some sample code - showing how the query is called through 
PHP? IMHO, at first pass it sounds like PHP rather than MySQL - but I 
have been wrong before (many, many times);).

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


[PHP] mysql problems, need help quick

2002-06-11 Thread Hawk

I'm filling a database with info, and I'm using id as identifiers in the
list, the id is auto increment, and I deleted one entry, now I have a hole
in the database, is there any way to fix this?
lets say I have
1
2
3
4
5
6
And I deleted 6
Now it looks like
1
2
3
4
5
7
8
9 and so on

is there somewhere the next number is located ?




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




RE: [PHP] mysql problems, need help quick

2002-06-11 Thread Jon Haworth

Hi Hawk,

(snip auto-incrementing PKs)

 is there somewhere the next number is located ?

No. Why would you care, anyway? The thing about PKs is that they have to be
unique, not sequential.

If you're *really* bothered by it, you'll have to dump the contents of the
table to a file, drop the table, recreate it, and import the contents into
the new table. I'd also suggest, if these numbers have to be sequential,
that you look hard at your db design to see if this is the right column to
use as a PK.

Incidentally, this is a PHP list. If you need to ask MySQL questions, please
join one of the lists at http://mysql.com/.

Cheers
Jon

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




Re: [PHP] mysql problems, need quick help

2002-06-11 Thread Adam Voigt

Primary Key's, by nature, are designed to always be uniqiue, which
means that even if you delete row 6, the next row you insert will be
10 because there is no id 10. If you simply need to get the list of
items in a query, in the order they were inserted, I would suggest using
something like: SELECT * FROM table_name ORDER BY id ASC;
Which will select everything from table_name (with no criteria such as a
WHERE clause) and order it by the id in ascending order (ie,
1,2,3,4,etc.). Avid SQL users will be quick to point out that ASC is not
required as ascending is the default pattern in an order by, but I still
like to specify. =) Let me know if you have any other questions.

Adam Voigt
[EMAIL PROTECTED]

On Tue, 2002-06-11 at 08:52, Hawk wrote:
 I'm filling a database with info, and I'm using id as identifiers in
the
 list, the id is auto increment, and I deleted one entry, now I have a
hole
 in the database, is there any way to fix this?
 lets say I have
 1
 2
 3
 4
 5
 6
 And I deleted 6
 Now it looks like
 1
 2
 3
 4
 5
 7
 8
 9 and so on
 
 is there somewhere the next number is located ?
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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




[PHP] mysql problems

2002-03-12 Thread Maarten Weyn

Hi on this code:

$link = mysql_connect(localhost, login, passwd);
 mysql_select_db(table);
 $result = mysql_query(select * from table);
 while ($row = mysql_fetch_object($result)) {
  echo $row-ID;
  echo $row-Drank;
 }
 mysql_free_result($result);

 mysql_close($link);

It resulst in
Warning: Supplied argument is not a valid MySQL result resource in
c:\program files\apache group\apache\htdocs\index.php on line 13
Warning: Supplied argument is not a valid MySQL result resource in
c:\program files\apache group\apache\htdocs\index.php on line 17

line 13 =  while ($row = mysql_fetch_object($result)) {
line 17 =  mysql_free_result($result);

I'm running an Apache/1.3.23 on a win 2000 with PHP Version 4.1.2 and mysql
3.23.39.


Does it not recoginze this mysql_... statements?


Maarten



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




Re: [PHP] mysql problems

2002-03-12 Thread hugh danaher

Maarten,

Perhaps table isn't the name of the table you want.

If mysql can't find the table (in line 13?), your $result variable is empty
and this causes (line 17?) to fail also.

Hope this helps,
Hugh
- Original Message -
From: Maarten Weyn [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, March 12, 2002 5:19 PM
Subject: [PHP] mysql problems


 Hi on this code:

 $link = mysql_connect(localhost, login, passwd);
  mysql_select_db(table);
  $result = mysql_query(select * from table);
  while ($row = mysql_fetch_object($result)) {
   echo $row-ID;
   echo $row-Drank;
  }
  mysql_free_result($result);

  mysql_close($link);

 It resulst in
 Warning: Supplied argument is not a valid MySQL result resource in
 c:\program files\apache group\apache\htdocs\index.php on line 13
 Warning: Supplied argument is not a valid MySQL result resource in
 c:\program files\apache group\apache\htdocs\index.php on line 17

 line 13 =  while ($row = mysql_fetch_object($result)) {
 line 17 =  mysql_free_result($result);

 I'm running an Apache/1.3.23 on a win 2000 with PHP Version 4.1.2 and
mysql
 3.23.39.


 Does it not recoginze this mysql_... statements?


 Maarten



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



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




RE: [PHP] mysql problems

2002-03-12 Thread Narvaez, Teresa

I agree with Hugh. I think it is always a good idea to check for return
values of any function call.  So, I'd replace this line: 
 $result = mysql_query(select * from table);
 with

 $result = mysql_query(select * from table);
or die(Unable to connect to SQL server: . mysql_error());

-Teresa

-Original Message-
From: hugh danaher [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 12, 2002 8:27 PM
To: Maarten Weyn; php
Subject: Re: [PHP] mysql problems


Maarten,

Perhaps table isn't the name of the table you want.

If mysql can't find the table (in line 13?), your $result variable is empty
and this causes (line 17?) to fail also.

Hope this helps,
Hugh
- Original Message -
From: Maarten Weyn [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, March 12, 2002 5:19 PM
Subject: [PHP] mysql problems


 Hi on this code:

 $link = mysql_connect(localhost, login, passwd);
  mysql_select_db(table);
  $result = mysql_query(select * from table);
  while ($row = mysql_fetch_object($result)) {
   echo $row-ID;
   echo $row-Drank;
  }
  mysql_free_result($result);

  mysql_close($link);

 It resulst in
 Warning: Supplied argument is not a valid MySQL result resource in
 c:\program files\apache group\apache\htdocs\index.php on line 13
 Warning: Supplied argument is not a valid MySQL result resource in
 c:\program files\apache group\apache\htdocs\index.php on line 17

 line 13 =  while ($row = mysql_fetch_object($result)) {
 line 17 =  mysql_free_result($result);

 I'm running an Apache/1.3.23 on a win 2000 with PHP Version 4.1.2 and
mysql
 3.23.39.


 Does it not recoginze this mysql_... statements?


 Maarten



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



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



[PHP] PHP MySQL problems, updating database..

2002-01-17 Thread Hawk

Having a problem with this, I have a working login that supports multiple
users, and I'm trying to make it possible for the users to change their own
settings etc, but I get killed when trying to send the data to the MySQL
database.
To connect I use mysql_connect($host,$user,$pswd) and mysql_select_db($db)

the retrieving data from the form works since I belive, since it showed up
when I added a print $the vars  but I don't know how to save it to the
database..

I might be missing some line or maybe it's just because I'm a newbie or
something.. ;D
anyway.. I use something similiar to this
$query = UPDATE users SET email='$email'; // and so on..
$result = mysql_query($query) or die (blabla);

I don't get any error lines or anything, the only thing that shows is the
blabla thing.

I also tried INSERT INTO in the query but that didn't make any difference :p

if anyone could tell me what I'm doing wrong I would be happy.. :p
the best way to learn is to ask people that know :p

Hawk



-- 
PHP General 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] PHP MySQL problems, updating database..

2002-01-17 Thread Erik Price

The reason you aren't seeing any errors is because you used or 
die() -- to the best of my knowledge, this replaces any standard errors 
that PHP would normally generate.

It appears that you have omitted the second argument to mysql_query().  
A common mistake that I've made many times myself.  You need to specify 
the connection parameters in the second argument.

$result = mysql_query($sql, $db); // $db is mysql_connect(host, user, 
pass) or whatever you use

You would have gotten an error message telling you this if you weren't 
using or die... or die can be helpful but it can also occlude 
valuable information.

Good luck I hope this works,


Erik



On Thursday, January 17, 2002, at 01:18  PM, Hawk wrote:

 Having a problem with this, I have a working login that supports 
 multiple
 users, and I'm trying to make it possible for the users to change their 
 own
 settings etc, but I get killed when trying to send the data to the MySQL
 database.
 To connect I use mysql_connect($host,$user,$pswd) and 
 mysql_select_db($db)

 the retrieving data from the form works since I belive, since it showed 
 up
 when I added a print $the vars  but I don't know how to save it to the
 database..

 I might be missing some line or maybe it's just because I'm a newbie or
 something.. ;D
 anyway.. I use something similiar to this
 $query = UPDATE users SET email='$email'; // and so on..
 $result = mysql_query($query) or die (blabla);

 I don't get any error lines or anything, the only thing that shows is 
 the
 blabla thing.

 I also tried INSERT INTO in the query but that didn't make any 
 difference :p

 if anyone could tell me what I'm doing wrong I would be happy.. :p
 the best way to learn is to ask people that know :p

 Hawk


-- 
PHP General 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] PHP MySQL problems, updating database..

2002-01-17 Thread Dennis Moore

Try using mysql_error() to display the mysql error message before issuing
your die().   this will give more information to troubleshoot.  You may not
have the right privileges set up in your database where you can update or
insert into the database or table.

/dkm


- Original Message -
From: Hawk [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, January 17, 2002 1:18 PM
Subject: [PHP] PHP  MySQL problems, updating database..


 Having a problem with this, I have a working login that supports multiple
 users, and I'm trying to make it possible for the users to change their
own
 settings etc, but I get killed when trying to send the data to the MySQL
 database.
 To connect I use mysql_connect($host,$user,$pswd) and mysql_select_db($db)

 the retrieving data from the form works since I belive, since it showed up
 when I added a print $the vars  but I don't know how to save it to the
 database..

 I might be missing some line or maybe it's just because I'm a newbie or
 something.. ;D
 anyway.. I use something similiar to this
 $query = UPDATE users SET email='$email'; // and so on..
 $result = mysql_query($query) or die (blabla);

 I don't get any error lines or anything, the only thing that shows is the
 blabla thing.

 I also tried INSERT INTO in the query but that didn't make any difference
:p

 if anyone could tell me what I'm doing wrong I would be happy.. :p
 the best way to learn is to ask people that know :p

 Hawk



 --
 PHP General 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 General 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] PHP MySQL problems, updating database..

2002-01-17 Thread Miles Thompson

Hawk,

If you have a working login, can we safely assume that there is information 
in the database for each user? If so, then we won't bother discussing 
insert statements, but concentrate on updates. We'll also assume that $user 
has update privileges on the database.

The normal form of an update query is as you describe, I'm just going to 
flesh it out a bit ...

$query = UPDATE users SET email='$email', phone = '$phone'  WHERE user_id 
= '$user_id' ;
echo $query;
$result = mysql_query( $query) or die( mysql_errno() . : .mysql_error() );

The WHERE clause makes certain that everyone's email isn't updated with the 
contents of $email.

The echo is useful for debugging - you may be assuming that the update 
statement is correct, but it turns out that a key variable is missing, 
contains no data, or there are single quotes around numerical fields, etc.

The revised die() will print out MySQL's error code and error message, 
which may or may not be helpful.

This may still not work, but we've more information to work on. Please let 
us know what happens.

Cheers - Miles Thompson


At 07:18 PM 1/17/2002 +0100, Hawk wrote:
Having a problem with this, I have a working login that supports multiple
users, and I'm trying to make it possible for the users to change their own
settings etc, but I get killed when trying to send the data to the MySQL
database.
To connect I use mysql_connect($host,$user,$pswd) and mysql_select_db($db)

the retrieving data from the form works since I belive, since it showed up
when I added a print $the vars  but I don't know how to save it to the
database..

I might be missing some line or maybe it's just because I'm a newbie or
something.. ;D
anyway.. I use something similiar to this
$query = UPDATE users SET email='$email'; // and so on..
$result = mysql_query($query) or die (blabla);

I don't get any error lines or anything, the only thing that shows is the
blabla thing.

I also tried INSERT INTO in the query but that didn't make any difference :p

if anyone could tell me what I'm doing wrong I would be happy.. :p
the best way to learn is to ask people that know :p

Hawk



--
PHP General 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 General 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]