Yeah, I just now noticed thatVladSun wrote:You don't assign value to $result anywhere in your code ...
Very complicated SQL Query with 2 nested - not working
Moderator: General Moderators
Re: Very complicated SQL Query with 2 nested - not working
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Very complicated SQL Query with 2 nested - not working
Ok.
I now have this error:
I now have this error:
Based on this code: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
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);
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Very complicated SQL Query with 2 nested - not working
Code: Select all
$result = mysql_query("SELECT * FROM matternudge WHERE matterno = '$matterno'"); mysql_query($result) or die(mysql_error());
http://php.net/mysql_query
There are 10 types of people in this world, those who understand binary and those who don't
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Very complicated SQL Query with 2 nested - not working
.... yes...?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Very complicated SQL Query with 2 nested - not working
Read it!simonmlewis wrote:.... yes...?
Especially the examples section.
There are 10 types of people in this world, those who understand binary and those who don't
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Very complicated SQL Query with 2 nested - not working
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.
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.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Very complicated SQL Query with 2 nested - not working
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:
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:
Really?!? Pressing PgDn key twice is a "long page" ???...That is one very long page to read...
There are 10 types of people in this world, those who understand binary and those who don't
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Very complicated SQL Query with 2 nested - not working
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.
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.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Very complicated SQL Query with 2 nested - not working
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.
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.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Very complicated SQL Query with 2 nested - not working
You learn from fixes, especially when they are explained.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Very complicated SQL Query with 2 nested - not working
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..