Jump to content

Brilliant Minds Tackle This [Warning: Missing argument 1 for display_jobs( )...]


ridiculous

Recommended Posts

[b][color=purple]error:[/color][/b]
----------

Warning: Missing argument 1 for display_jobs() in /home/content/s/t/a/starsonline/html/strippedgirl/u/output_fns.php on line 44

-----------


[b][color=purple]code:[/color][/b]


function display_jobs($open)
{
  //display the table of Jobs

  // set global variable, so we can test later if this is on the page
  global $jobs;
  $jobs = true;
?>
  <br>
  <form name=bm_table action="delete_bms.php" method=post>
  <table width=300 cellpadding=2 cellspacing=0>
  <?
  $color = "#cccccc";
  echo "<tr bgcolor=$color><td><strong>Position</strong></td>";
  echo "<td><strong>Apply?</strong></td></tr>";
  if (is_array($job_array) && count($job_array)>0)
  {
    foreach ($job_array as $job)
    {
      if ($color == "#cccccc")
        $color = "#ffffff";
      else
        $color = "#cccccc";
      // remember to call htmlspecialchars() when we are displaying user data
      echo "<tr bgcolor=$color><td><a href=\"$job\">".htmlspecialchars($job)."</a></td>";
      echo "<td><input type=checkbox name=\"del_me[]\"
            value=\"$job\"></td>";
      echo "</tr>";
    }
  }
  else
    echo "<tr><td>No positions currently open.</td></tr>";
?>
  </table>
  </form>
<?
}



----------------


I'm just a blonde lost in a world of fierce computer programmers...can your subtle touch of the keyboard save my soul from eternal damnation?


Link to comment
Share on other sites

Probably not, but I would really like to know how to tackle this problem. My instinct tells me I have to "declare" the variable 'open' in this function, and this is what PHP wants when it announces I'm missing an argument. How to do this, however, isn't especially clear to me. Maybe if I stare at the logical relationships elsewhere I'll figure it out before my breasts begin to sag.
Link to comment
Share on other sites

"Missing arguement 1 for display_jobs()"

You get this error when you call a function (in your case, display_jobs()) and forget to pass it the proper parameters required.. in your case, display_jobs requires the something in it's () to pass into the function as "$open" but in your function you dont use open, so you can take that out.. change your function creation to:

function display_jobs()
{

and it'll run fine.. unless there are other errors.
Link to comment
Share on other sites

I'm really trying desperately to learn here. I've been working on a simple function to retrieve data from a MYSQL db all day long. I'm getting wrecked, and I don't know why. I have no errors from PHP, and I am connecting to the MySQL db through the connection script-so far as I can tell.

However, I'm not able to see any of the data that I query with the SELECT statement. What has me even more confused is that when I purposely enter the wrong values into the SELECT script, there is the same result as before: blank screen.

So I'm doing a narrative. Well, my guess has been that the retrieval script I have is drawing the data from MySQL and that the output script I have isn't getting the data. But despite hours of searching, I still haven't found an answer online as to where I'm wrong and I'm praying that one of you bad boys can pick this up in a couple of seconds.


[color=purple]RETRIEVAL SCRIPT[/color]
------------------------------------------------
<?
require_once("db_fns.php");

function get_jobs()
{
  //extract from the database all the URLs this user has stored
  if (!($conn = db_connect()))
    return false;
  $result = mysql_query( "SELECT *
                          FROM jobs");
  if (!$result)
    print 'sql script aint workin';

  //create an array of the URLs
  $job_array = array();
  for ($count = 1; $row = mysql_fetch_row ($result); ++$count)
  {
    $job_array[$count] = $row[0];
  } 
  return $job_array;
}


--------------------------------------------------
[b][color=pink]

Output Script:[/color][/b]


function display_jobs()
{
  //display the table of Jobs


?>
  <br>
  <form name=jobs action="apply.php" method=post>
  <table width=600 cellpadding=2 cellspacing=0>
  <?
  $color = "#cccccc";
  echo "<tr bgcolor=$color><td><strong>Position</strong></td>";
  echo "<td><strong>Apply?</strong></td></tr>";
  if (is_array($job_array) && count($job_array)>0)
  {
    foreach ($job_array as $job)
    {
      if ($color == "#cccccc")
        $color = "#ffffff";
      else
        $color = "#cccccc";
 
      echo "</td>";
      echo "</tr>";
    }
  }
  else
    echo "<tr><td>No positions currently open.</td></tr>";
?>
  </table>
  </form>
<?
}



-------------------

ANY help at all on this would be great.








function display_jobs()
{
  //display the table of Jobs


?>
  <br>
  <form name=jobs action="apply.php" method=post>
  <table width=600 cellpadding=2 cellspacing=0>
  <?
  $color = "#cccccc";
  echo "<tr bgcolor=$color><td><strong>Position</strong></td>";
  echo "<td><strong>Apply?</strong></td></tr>";
  if (is_array($job_array) && count($job_array)>0)
  {
    foreach ($job_array as $job)
    {
      if ($color == "#cccccc")
        $color = "#ffffff";
      else
        $color = "#cccccc";
 
      echo "</td>";
      echo "</tr>";
    }
  }
  else
    echo "<tr><td>No positions currently open.</td></tr>";
?>
  </table>
  </form>
<?
}






Link to comment
Share on other sites

Instead of testing for (!$result) add 

[code] or die("SELECT Error: ".mysql_error());[/code]

after your database query.  If the query failing is your problem this added line will print the error to the screen.  Hopefully giving you some insight into where its going wrong.
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.