Announcement

Collapse
No announcement yet.

Php & mysql problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Php & mysql problem

    I've done several simple scripts for my site. When I'm trying to add these lines of code to one of the scripts, php produces the warning like:

    Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\sducc\mainfile.php on line 71

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\sducc\mainfile.php on line 74

    <!-- Clipboard start ["problem part"] -->
    $request = mysql_query("select gens, action from module_actions where moduleid=1");
    $numrows = mysql_numrows($request);

    for($i=0; $i<$numrows; $i++) {
    $action = mysql_fetch_array($request);
    $module_actions[$i] =$action;
    }
    <!-- Clipboard end -->

    Before these fragment I use contructions like and they work fine:

    <!-- Clipboard start -->
    $query = "select path, action, layout, weight, id from modules ".
    "where active=1 order by layout and weight";
    $request = mysql_query($query);
    $numrows = mysql_numrows($request);
    <!-- Clipboard end -->

  • #2
    That error could be due to one of three reasons (that I know of, at least):
    1. You aren't connected to the database
    2. The data you're trying to take from the table (gens and action, in this case), doesn't exist
    3. The table itself doesn't exist
    To be absolutely positive as to the reason, you can change this:

    PHP Code:
    $request mysql_query("select gens, action from module_actions where moduleid=1"); 
    ...to this

    PHP Code:
    $request mysql_query("select gens, action from module_actions where moduleid=1") or die(mysql_error()); 

    Comment


    • #3
      Yo!

      Originally posted by Silverwolf
      PHP Code:
      $request mysql_query("select gens, action from module_actions where moduleid=1") or die(mysql_error()); 


      You was right, a lot of thanks... As you supposed it said following:
      "Unknown column 'gens' in 'field list'"

      I forgot to update database structure on my sql server. Sometimes it happens...

      Comment

      Related Topics

      Collapse

      Working...
      X