Jump to content

[SOLVED] mysql_fetch_row problems with integers


Jeffyh

Recommended Posts

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.

 

 

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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... **

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.