Jeffyh Posted September 22, 2008 Share Posted September 22, 2008 I'm new to php/SQL and was hoping someone could help. I've spent hours trying to figure out what's wrong but I honestly have no idea. Any help would be greatly appreciated. table SubNav: ========== Parent (varchar)Group (int)Depth (varchar)S1 (varchar) Patents21Specification Specification22US Application code: =========== 124 $Result2Match = mysql_query("SELECT Group FROM SubNav WHERE Parent='$Type'"); 125 126 while($Row2Match = mysql_fetch_row($Result2Match)){ 127 echo "<option>$Row2Match[1]</option>"; 128 129 $Result2Match2 = mysql_query("SELECT Parent FROM SubNav WHERE Group=$Row2Match[1] AND Depth=2"); 130 131 while($Row2Match2 = mysql_fetch_row($Result2Match2)){ 132 echo "<option>".$Row2Match2[0]."</option>"; 133 } 134 } $Type = Patents Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\Program Files\EasyPHP 2.0b1\www\Data.php on line 126 Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\Program Files\EasyPHP 2.0b1\www\Data.php on line 131 It doesn't echo anything. Quote Link to comment https://forums.phpfreaks.com/topic/125346-solved-mysql_fetch_row-problems-with-integers/ Share on other sites More sharing options...
Maq Posted September 22, 2008 Share Posted September 22, 2008 What errors are you getting? If they are not on please turn them on and tell us what you get. Also please debug. Echo out your results and make sure they make sense and are correct. Quote Link to comment https://forums.phpfreaks.com/topic/125346-solved-mysql_fetch_row-problems-with-integers/#findComment-647886 Share on other sites More sharing options...
FVxSF Posted September 22, 2008 Share Posted September 22, 2008 After $ResultMatch = mysql_query("SELECT Group FROM SubNav WHERE Parent='$Type'"); add this: if( !$ResultMatch ) { die( mysql_error() ); } This will tell you the error. Quote Link to comment https://forums.phpfreaks.com/topic/125346-solved-mysql_fetch_row-problems-with-integers/#findComment-647893 Share on other sites More sharing options...
Jeffyh Posted September 22, 2008 Author Share Posted September 22, 2008 After $ResultMatch = mysql_query("SELECT Group FROM SubNav WHERE Parent='$Type'"); add this: if( !$ResultMatch ) { die( mysql_error() ); } This will tell you the error. I'm really new to php/sql and posting help in forums. Sorry if I don't post all the info, but if you let me know, I'll get it up asap. This is the error that I got. "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 'Group FROM SubNav WHERE Parent='Patents'' at line 1" Quote Link to comment https://forums.phpfreaks.com/topic/125346-solved-mysql_fetch_row-problems-with-integers/#findComment-647901 Share on other sites More sharing options...
Maq Posted September 22, 2008 Share Posted September 22, 2008 Try this: $ResultMatch = mysql_query("SELECT Group FROM SubNav WHERE Parent='" . $Type . "'"); Quote Link to comment https://forums.phpfreaks.com/topic/125346-solved-mysql_fetch_row-problems-with-integers/#findComment-647911 Share on other sites More sharing options...
Jeffyh Posted September 22, 2008 Author Share Posted September 22, 2008 Try this: $ResultMatch = mysql_query("SELECT Group FROM SubNav WHERE Parent='" . $Type . "'"); still the same error... out of curiousity. What does changing that do? Quote Link to comment https://forums.phpfreaks.com/topic/125346-solved-mysql_fetch_row-problems-with-integers/#findComment-647915 Share on other sites More sharing options...
FVxSF Posted September 22, 2008 Share Posted September 22, 2008 One thing that caught my eye was "Group" GROUP is sql syntax maybe that's causing the problem? If Maq's advice doesn't work try renaming the Group field to something else. Try giving it a prefix like gr_Group or something. I had a similar problem when I first started only I had a field named Order. ** getting beaten to posting... ** Quote Link to comment https://forums.phpfreaks.com/topic/125346-solved-mysql_fetch_row-problems-with-integers/#findComment-647918 Share on other sites More sharing options...
Jeffyh Posted September 22, 2008 Author Share Posted September 22, 2008 One thing that caught my eye was "Group" GROUP is sql syntax maybe that's causing the problem? If Maq's advice doesn't work try renaming the Group field to something else. Try giving it a prefix like gr_Group or something. I had a similar problem when I first started only I had a field named Order. ** getting beaten to posting... ** Wow. I renamed 'Group' to 'Grouping' and everything works now. That's kind of annoying that was the problem, but I guess that's what happens w/o knowing normal commands and syntax. Thanks guys for the help! Quote Link to comment https://forums.phpfreaks.com/topic/125346-solved-mysql_fetch_row-problems-with-integers/#findComment-647924 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.