RE: [PHP] db query not working

2007-03-07 Thread Jim Moseby
snip
 
 It dumps the table fine, works the explode, outputs the string in the 
 echo command the way I expect, but doesn't place the value in 
 tmphitsmag 
 table.

Does it insert an empty record?

JM

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



Re: [PHP] db query not working

2007-03-07 Thread Tijnema !

On 3/7/07, Ed Curtis [EMAIL PROTECTED] wrote:


I have this code:

mysql_connect ($local_host, $local_user, $local_pass);
mysql_select_db ($local_db);

mysql_query (DELETE FROM tmphitsmag);

$result = mysql_query (SELECT DISTINCT company FROM view_log WHERE
company != '');

if ($row = mysql_fetch_array($result)) {

do {

$magazine_path = $row['company'];
$magazine_path = explode(/, $magazine_path);

echo str_replace(_,  , $magazine_path[2]) . br;

mysql_query (INSERT INTO tmphitsmag (magazine)
   VALUES('$magazine_path[2]');



Look how many ( you have, and how many ) you have
that's the problem...
try
mysql_query (INSERT INTO tmphitsmag (magazine)
VALUES('$magazine_path[2]'));
that should solve the problem

Tijnema

   } while($row = mysql_fetch_array($result));


} mysql_close();

It dumps the table fine, works the explode, outputs the string in the
echo command the way I expect, but doesn't place the value in tmphitsmag
table.

Anyone have a clue?

Thanks,

Ed

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




Re: [PHP] db query not working as expected

2007-03-07 Thread Tijnema !

On 3/7/07, Ed Curtis [EMAIL PROTECTED] wrote:


I have this code:

mysql_connect ($local_host, $local_user, $local_pass);
mysql_select_db ($local_db);

mysql_query (DELETE FROM tmphitsmag);

$result = mysql_query (SELECT DISTINCT company FROM view_log WHERE
company != '');

if ($row = mysql_fetch_array($result)) {

do {

$magazine_path = $row['company'];
$magazine_path = explode(/, $magazine_path);

echo str_replace(_,  , $magazine_path[2]) . br;

mysql_query (INSERT INTO tmphitsmag (magazine)
VALUES  ('$magazine_path[2]'));



Not sure about it but try this:
 mysql_query (INSERT INTO tmphitsmag (magazine) VALUES
('.$magazine_path[2].'));

Tijnema

   } while($row = mysql_fetch_array($result));


} mysql_close();

The code dumps the first table fine, selects, manipulates, and echoes
the string the way I expect, but fails to input the string into the
tmphitsmag table.

Any ideas?

Thanks,

Ed

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




Re: [PHP] db query not working as expected

2007-03-07 Thread Tijnema !

On 3/7/07, Ed Curtis [EMAIL PROTECTED] wrote:


I have this code:

mysql_connect ($local_host, $local_user, $local_pass);
mysql_select_db ($local_db);

mysql_query (DELETE FROM tmphitsmag);

$result = mysql_query (SELECT DISTINCT company FROM view_log WHERE
company != '');

if ($row = mysql_fetch_array($result)) {

do {

$magazine_path = $row['company'];
$magazine_path = explode(/, $magazine_path);

echo str_replace(_,  , $magazine_path[2]) . br;

mysql_query (INSERT INTO tmphitsmag (magazine)
VALUES  ('$magazine_path[2]'));




what about adding the usual or die?
mysql_query (INSERT INTO tmphitsmag (magazine)VALUES
('$magazine_path[2]')) or die(mysql_error());

Tijnema

   } while($row = mysql_fetch_array($result));


} mysql_close();

The code dumps the first table fine, selects, manipulates, and echoes
the string the way I expect, but fails to input the string into the
tmphitsmag table.

Any ideas?

Thanks,

Ed

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




Re: [PHP] db query not working as expected

2007-03-07 Thread cajbecu
try:

mysql_query (INSERT INTO tmphitsmag (magazine) VALUES
   ('{$magazine_path[2]}'));

cajb.

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



Re: [PHP] db query not working as expected

2007-03-07 Thread Stut

Ed Curtis wrote:
mysql_query (INSERT INTO tmphitsmag (magazine) 
VALUES ('$magazine_path[2]'));


Replace that with this...


mysql_query (INSERT INTO tmphitsmag (magazine) VALUES 


 ('.mysql_real_escape_string($magazine_path[2]).'));

-Stut

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



Re: [PHP] db query not working

2007-03-07 Thread Satyam
I saw two people pointing two errors on the SQL insert statement which you 
would have found yourself had you put the 'or die()' at the end of the 
query, as someone else suggested.  Do never leave any query without the 'or 
die()' after it (or any other means to check if mysql_query returns anything 
not false).  This would have saved lots of your time, our time, everybody's 
bandwidth and would avoid your asking everybody again for the next error you 
make.  We all make errors, none of us is above that, that's why, at least in 
my case, I never fail to add the or die() at the end.  That's why the 
developers of function libraries have put some means of reporting errors 
back.  It takes time for providing good error reporting.  You are wasting 
that effort as well.


Do you deserve all this speech?  No more than the dozens who write what I 
call 'ballistic' code: code you have no control over once it launches. 
Guided missiles are far better.  Anyway, you got it because I had time to 
rant about this.


Satyam



- Original Message - 
From: Ed Curtis [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Wednesday, March 07, 2007 3:28 PM
Subject: [PHP] db query not working



I have this code:

mysql_connect ($local_host, $local_user, $local_pass);
mysql_select_db ($local_db);

mysql_query (DELETE FROM tmphitsmag);

$result = mysql_query (SELECT DISTINCT company FROM view_log WHERE 
company != '');


if ($row = mysql_fetch_array($result)) {

do {

$magazine_path = $row['company'];
$magazine_path = explode(/, $magazine_path);

echo str_replace(_,  , $magazine_path[2]) . br;

mysql_query (INSERT INTO tmphitsmag (magazine) 
VALUES('$magazine_path[2]');


} while($row = mysql_fetch_array($result));

} mysql_close();

It dumps the table fine, works the explode, outputs the string in the echo 
command the way I expect, but doesn't place the value in tmphitsmag table.


Anyone have a clue?

Thanks,

Ed

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



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.7/712 - Release Date: 06/03/2007 
15:42





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



Re: [PHP] db query not working

2007-03-07 Thread Ed Curtis

Satyam wrote:
I saw two people pointing two errors on the SQL insert statement which 
you would have found yourself had you put the 'or die()' at the end of 
the query, as someone else suggested.  Do never leave any query without 
the 'or die()' after it (or any other means to check if mysql_query 
returns anything not false).  This would have saved lots of your time, 
our time, everybody's bandwidth and would avoid your asking everybody 
again for the next error you make.  We all make errors, none of us is 
above that, that's why, at least in my case, I never fail to add the or 
die() at the end.  That's why the developers of function libraries have 
put some means of reporting errors back.  It takes time for providing 
good error reporting.  You are wasting that effort as well.


Do you deserve all this speech?  No more than the dozens who write what 
I call 'ballistic' code: code you have no control over once it launches. 
Guided missiles are far better.  Anyway, you got it because I had time 
to rant about this.


Satyam


 I wasted no more bandwidth than you did with your rant. My code post 
was edited from the original code and that's where the mistake was made, 
not in the code itself. And I do, by the way, end all my queries with 
or die(). I just left it out of the edit. Besides, the problem is fixed 
now. Thanks to all that helped.


Ed

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



Re: [PHP] db query not working

2007-03-07 Thread Jochem Maas
Satyam wrote:
 I saw two people pointing two errors on the SQL insert statement which
 you would have found yourself had you put the 'or die()' at the end of
 the query, as someone else suggested.  Do never leave any query without
 the 'or die()' after it (or any other means to check if mysql_query
 returns anything not false).  This would have saved lots of your time,
 our time, everybody's bandwidth and would avoid your asking everybody
 again for the next error you make.  We all make errors, none of us is
 above that, that's why, at least in my case, I never fail to add the or
 die() at the end.  That's why the developers of function libraries have
 put some means of reporting errors back.  It takes time for providing
 good error reporting.  You are wasting that effort as well.
 
 Do you deserve all this speech? 

yes. no error checking, no attempt at self improvement and above all
no patience when it comes to waiting for an answer.

...

 I call 'ballistic' code: code you have no control over once it launches.
 Guided missiles are far better.  

might I suggest that the word 'better' shouldn't be used to describe any kind
of missile other than a decommissioned one. 'better' ways of killing people
are things generally only sought after by fundamentalists, arms-industry 
employees
and megalomaniacs (it just springs to mind that a certain leader of the [not so]
free world could happily sit in any of those categories)

gun analogies suck almost as much as guns, as opposed to good old rant, which, 
as
long as they're not combined with guns are fairly harmless and quite often 
informative.

Anyway, you got it because I had time
 to rant about this.

we make time to rant ;-)

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



Re: [PHP] db query not working

2007-03-07 Thread Satyam
- Original Message - 
From: Jochem Maas [EMAIL PROTECTED]




Satyam wrote:

I saw two people pointing two errors on the SQL insert statement which
you would have found yourself had you put the 'or die()' at the end of
the query, as someone else suggested.  Do never leave any query without
the 'or die()' after it (or any other means to check if mysql_query
returns anything not false).  This would have saved lots of your time,
our time, everybody's bandwidth and would avoid your asking everybody
again for the next error you make.  We all make errors, none of us is
above that, that's why, at least in my case, I never fail to add the or
die() at the end.  That's why the developers of function libraries have
put some means of reporting errors back.  It takes time for providing
good error reporting.  You are wasting that effort as well.

Do you deserve all this speech?


yes. no error checking, no attempt at self improvement and above all
no patience when it comes to waiting for an answer.

...


I call 'ballistic' code: code you have no control over once it launches.
Guided missiles are far better.


might I suggest that the word 'better' shouldn't be used to describe any 
kind
of missile other than a decommissioned one. 'better' ways of killing 
people
are things generally only sought after by fundamentalists, arms-industry 
employees
and megalomaniacs (it just springs to mind that a certain leader of the 
[not so]

free world could happily sit in any of those categories)



My apologies, it was not a happy comparison.

gun analogies suck almost as much as guns, as opposed to good old rant, 
which, as
long as they're not combined with guns are fairly harmless and quite often 
informative.


Anyway, you got it because I had time

to rant about this.


we make time to rant ;-)



It is an old guy thing, at least in my case (trivia: I was born the day 
after the ENIAC was turned off)


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.7/712 - Release Date: 06/03/2007 
15:42




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



Re: [PHP] db query not working

2007-03-07 Thread Ed Curtis
It is an old guy thing, at least in my case (trivia: I was born the day 
after the ENIAC was turned off)


Aha! October 3, 1955

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



Re: [PHP] db query not working

2007-03-07 Thread David Robley
Satyam wrote:
 
 It is an old guy thing, at least in my case (trivia: I was born the day
 after the ENIAC was turned off)

Young kids these days :-) I was born the month before it was turned _on_!




Cheers
-- 
David Robley

Why do we read left to right yet turn pages right to left?
Today is Boomtime, the 67th day of Chaos in the YOLD 3173. 

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