Page 2 of 2

Re: Very complicated SQL Query with 2 nested - not working

Posted: Wed Jan 21, 2009 10:00 am
by requinix
VladSun wrote:You don't assign value to $result anywhere in your code ...
Yeah, I just now noticed that :banghead: Not even present in the original code.

Re: Very complicated SQL Query with 2 nested - not working

Posted: Wed Jan 21, 2009 10:03 am
by simonmlewis
Ok.
I now have this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #5' at line 1
Based on this code:

Code: Select all

sqlconn=@mysql_connect("localhost","u","p");
$rs=@mysql_select_db("db",$sqlconn);
$result = mysql_query("SELECT * FROM matternudge WHERE matterno = '$matterno'");
mysql_query($result) or die(mysql_error());
if (mysql_num_rows($result)==0) 
  { 
    mysql_query("INSERT INTO matternudge (matterno, nudgedate) VALUES ('$matterno', '$nudgedate')");
    }
else
  {
  while ($row = mysql_fetch_object($result))
      {
        mysql_query ("UPDATE matternudge SET nudgedate = '$nudgedate' WHERE matterno = '$matterno'");
        }
  }
 
    mysql_free_result($result);
    mysql_close($sqlconn); 
 

Re: Very complicated SQL Query with 2 nested - not working

Posted: Wed Jan 21, 2009 10:07 am
by VladSun

Code: Select all

$result = mysql_query("SELECT * FROM matternudge WHERE matterno = '$matterno'");
mysql_query($result) or die(mysql_error());
:?
http://php.net/mysql_query

Re: Very complicated SQL Query with 2 nested - not working

Posted: Wed Jan 21, 2009 10:38 am
by simonmlewis
.... yes...?

Re: Very complicated SQL Query with 2 nested - not working

Posted: Wed Jan 21, 2009 10:39 am
by VladSun
simonmlewis wrote:.... yes...?
Read it!
Especially the examples section.

Re: Very complicated SQL Query with 2 nested - not working

Posted: Wed Jan 21, 2009 10:45 am
by simonmlewis
That is one very long page to read and find one small solution.

I have used this code method for a very long time, and in fact, further up the page this code is used for a different purpose, and it works!

So your blunt "read it" comment holds no strength here for me.
The previous supportive person has been very help to date, and I would like to thank them.

Regards, Simon.

Re: Very complicated SQL Query with 2 nested - not working

Posted: Wed Jan 21, 2009 11:56 am
by VladSun
I already knew in your previous thread ( viewtopic.php?f=1&t=93759 ) that you would continue asking for copy-paste code snippets. That's why I gave you those answers there and I'll continue to do it in this thread and all of your future threads until you start reading the manuals, thinking and stop copy-pasting blindly and asking for ready to use solutions.
When it happens you'll find out that I have been the most helpful person ;)

"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime."

EDIT:
...That is one very long page to read...
Really?!? Pressing PgDn key twice is a "long page" ???

Re: Very complicated SQL Query with 2 nested - not working

Posted: Thu Jan 22, 2009 3:16 am
by simonmlewis
Most helpful.
I'll ask you the way from London to Edinburgh, and you are the sort of person to say, "that's the way to the M25, follow that....".

Those who tend to use this forum have done just about all they can to find a solution, so need guidance and an answer, to save hours more work - from someone who knows the answer.

Being "helpful" is not giving me the sign to the M25, it's giving me the full route, otherwise I just keep looking and keep posting on here - wasting everyone's time.

Re: Very complicated SQL Query with 2 nested - not working

Posted: Thu Jan 22, 2009 3:21 am
by Eran
No, being helpful is explaining to you how to read your map instead of having you memorize the route. Vladsun was trying to help you understand what you did wrong instead of simply how to fix it.

It's too bad that you didn't take him up on his advice. Can't say it's too surprising though, as you say most people come here for simple quick fixes and not to learn.

Re: Very complicated SQL Query with 2 nested - not working

Posted: Thu Jan 22, 2009 3:33 am
by simonmlewis
You learn from fixes, especially when they are explained.

Re: Very complicated SQL Query with 2 nested - not working

Posted: Thu Jan 22, 2009 3:41 am
by Eran
Reading this thread, I'd have to say unfortunately that it seems you haven't learned much. But, hey what do I know, it's not like I do this for a living..