Jump to content


Photo

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


  • Please log in to reply
5 replies to this topic

#1 ridiculous

ridiculous
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 02 October 2006 - 11:51 PM

error:
----------

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

-----------


code:


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?




#2 ridiculous

ridiculous
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 02 October 2006 - 11:55 PM

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.

#3 tleisher

tleisher
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 02 October 2006 - 11:56 PM

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

#4 ridiculous

ridiculous
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 03 October 2006 - 12:09 AM

Great work. I'm sure that was simple for you, but I would have tried 15 other things before I came close to your solution. Thanks a lot. You made my 7:00-8:00pm ET.

AWESOME!!!

#5 ridiculous

ridiculous
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 03 October 2006 - 01:05 AM

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.


RETRIEVAL SCRIPT
------------------------------------------------
<?
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;
}


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


Output Script:



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>
<?
}








#6 Fehnris

Fehnris
  • Members
  • PipPipPip
  • Advanced Member
  • 48 posts

Posted 04 October 2006 - 12:23 AM

Instead of testing for (!$result) add 

or die("SELECT Error: ".mysql_error());

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users