[PHP-DB] Query Executes in MySQL Command Line, Not From PHP.

2002-11-15 Thread Hutchins, Richard
I'm having problems with a query. The query as it reads in my code is:

$sql_element_low = UPDATE $table SET medialow=NULL WHERE
.$_POST[tbl].contentID=.$_POST[id].;

All of the varibles get passed as expected. I know this because if I echo
the SQL out to the page, I get:

UPDATE levelone SET medialow=NULL WHERE 1contentID=1

When I type the echoed SQL directly into the MySQL command line, the query
executed just fine. However, when I try to let the code execute the query,
nothing happens. No, mysql_error(), nothing. 

All of the surrounding code is found below. $sql_media fires just fine and
deletes what it is supposed to. However, when the $sql_element_low query
gets called, it'll echo out just fine, but won't execute.

if(isset($_POST[delete][medialow])){
$sql_media = DELETE FROM media WHERE
mediaID=.$_POST[mediaID][0].;
//echo $sql_media./br;

mysql_query($sql_media) or die(mysql_error());

$table = tableNumToName($_POST[tbl]);

$sql_element_low = UPDATE $table SET medialow=NULL WHERE
.$_POST[tbl].contentID=.$_POST[id].;
echo $sql_element_low.br;

mysql_query($sql_element_low) or die(mysql_error());
}

Any ideas?

Thanks,
Rich

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




Re: [PHP-DB] Query Executes in MySQL Command Line, Not From PHP.

2002-11-15 Thread Marco Tabini
I don't think you can have column names that start with a number. Are
you sure you didn't mean to write:


$sql_element_low = UPDATE $table SET medialow=NULL WHERE
.$table.contentID=.$_POST[id].;

Otherwise, try adding a simple

die (mysql_error());

after the offending line and see what PHP tells you.


Marco
-- 

php|architect - The magazine for PHP Professionals
The first monthly worldwide magazine dedicated to PHP programmers

Come visit us at http://www.phparch.com!

---BeginMessage---
I'm having problems with a query. The query as it reads in my code is:

$sql_element_low = UPDATE $table SET medialow=NULL WHERE
.$_POST[tbl].contentID=.$_POST[id].;

All of the varibles get passed as expected. I know this because if I echo
the SQL out to the page, I get:

UPDATE levelone SET medialow=NULL WHERE 1contentID=1

When I type the echoed SQL directly into the MySQL command line, the query
executed just fine. However, when I try to let the code execute the query,
nothing happens. No, mysql_error(), nothing. 

All of the surrounding code is found below. $sql_media fires just fine and
deletes what it is supposed to. However, when the $sql_element_low query
gets called, it'll echo out just fine, but won't execute.

if(isset($_POST[delete][medialow])){
$sql_media = DELETE FROM media WHERE
mediaID=.$_POST[mediaID][0].;
//echo $sql_media./br;

mysql_query($sql_media) or die(mysql_error());

$table = tableNumToName($_POST[tbl]);

$sql_element_low = UPDATE $table SET medialow=NULL WHERE
.$_POST[tbl].contentID=.$_POST[id].;
echo $sql_element_low.br;

mysql_query($sql_element_low) or die(mysql_error());
}

Any ideas?

Thanks,
Rich

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



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


RE: [PHP-DB] Query Executes in MySQL Command Line, Not From PHP.

2002-11-15 Thread Marco Tabini
Uhm... are you sure it's not working? It's an update statement, maybe
the row has already the NULL value before you execute the query?

Otherwise, everything seems to be in order... sorry :-)


Marco
-- 

php|architect - The magazine for PHP Professionals
The first monthly worldwide magazine dedicated to PHP programmers

Come visit us at http://www.phparch.com!

---BeginMessage---
Marco,

Thanks for the quick response. I'm pretty sure it's legal to have MySQL
column names that begin with numbers. I do plenty of other queries on the
same database without incident. You might be thinking of the rule in PHP
where variables can't start with numbers. Found that one out the hard way.
By that time it was too late to change the column names to make writing
queries easier. Live 'n learn.

And if you look at the code I posted, there is mysql_query($sql_element_low)
or die(mysql_error()); but it does not return an error.

That's why I'm so baffled here. Everything SEEMS to be right.

 -Original Message-
 From: Marco Tabini [mailto:marcot;inicode.com]
 Sent: Friday, November 15, 2002 3:52 PM
 To: Hutchins, Richard
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Query Executes in MySQL Command Line, Not From
 PHP.
 
 
 I don't think you can have column names that start with a number. Are
 you sure you didn't mean to write:
 
 
 $sql_element_low = UPDATE $table SET medialow=NULL WHERE
 .$table.contentID=.$_POST[id].;
 
 Otherwise, try adding a simple
 
 die (mysql_error());
 
 after the offending line and see what PHP tells you.
 
 
 Marco
 -- 
 
 php|architect - The magazine for PHP Professionals
 The first monthly worldwide magazine dedicated to PHP programmers
 
 Come visit us at http://www.phparch.com!
 

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



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


RE: [PHP-DB] Query Executes in MySQL Command Line, Not From PHP.

2002-11-15 Thread Hutchins, Richard
It's definitely not working. A resulting page breaks each time the code runs
and I can see that the UPDATE operation has not taken place when I examine
the data in the database.

I know the problem is not with the resulting page because the page is built
to handle NULL and I can see that the database has not been changed where I
expect it to be.

I even changed the column definition from smallint to varchar just to see if
I was not permitted to set a smallint back to NULL, but the code didn't
perform properly even when the column was a varchar. ARGH!

Thanks for trying to help. This is so frustrating.

 -Original Message-
 From: Marco Tabini [mailto:marcot;inicode.com]
 Sent: Friday, November 15, 2002 4:14 PM
 To: Hutchins, Richard
 Cc: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Query Executes in MySQL Command Line, Not From
 PHP.
 
 
 Uhm... are you sure it's not working? It's an update statement, maybe
 the row has already the NULL value before you execute the query?
 
 Otherwise, everything seems to be in order... sorry :-)
 
 
 Marco
 -- 
 
 php|architect - The magazine for PHP Professionals
 The first monthly worldwide magazine dedicated to PHP programmers
 
 Come visit us at http://www.phparch.com!
 

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




Re: [PHP-DB] Query Executes in MySQL Command Line, Not From PHP.

2002-11-15 Thread Peter Beckman
Can you post the explain levelone here?  One thought is that 1contentID
is a char or varchar instead of an int.  Then again, if it were, that exact
code shouldn't have worked.

Are you sure you are doing the query using $sql_element_low and not
something else?  You may be echoing it but are you actually using the query
to execute, or did you copy the mysql_query() command from another line and
forget to change the var?

Also, I hate . and ., makes for messy life.  Try this:

$sql_element_low = UPDATE {$table} set medialow=NULL WHERE 
{$_POST['tbl']}contentID={$_POST['id']};

Also, does medialow have a unique index on it?  This could cause it to
fail.  Or is medialow defined as NOT NULL?

Peter

On Fri, 15 Nov 2002, Hutchins, Richard wrote:

 I'm having problems with a query. The query as it reads in my code is:

 $sql_element_low = UPDATE $table SET medialow=NULL WHERE
 .$_POST[tbl].contentID=.$_POST[id].;

 All of the varibles get passed as expected. I know this because if I echo
 the SQL out to the page, I get:

 UPDATE levelone SET medialow=NULL WHERE 1contentID=1

 When I type the echoed SQL directly into the MySQL command line, the query
 executed just fine. However, when I try to let the code execute the query,
 nothing happens. No, mysql_error(), nothing.

 All of the surrounding code is found below. $sql_media fires just fine and
 deletes what it is supposed to. However, when the $sql_element_low query
 gets called, it'll echo out just fine, but won't execute.

   if(isset($_POST[delete][medialow])){
   $sql_media = DELETE FROM media WHERE
 mediaID=.$_POST[mediaID][0].;
   //echo $sql_media./br;

   mysql_query($sql_media) or die(mysql_error());

   $table = tableNumToName($_POST[tbl]);

   $sql_element_low = UPDATE $table SET medialow=NULL WHERE
 .$_POST[tbl].contentID=.$_POST[id].;
   echo $sql_element_low.br;

   mysql_query($sql_element_low) or die(mysql_error());
   }

 Any ideas?

 Thanks,
 Rich

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


---
Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation
[EMAIL PROTECTED] http://www.purplecow.com/
---


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