ridiculous Posted October 2, 2006 Share Posted October 2, 2006 [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? Quote Link to comment https://forums.phpfreaks.com/topic/22812-brilliant-minds-tackle-this-warning-missing-argument-1-for-display_jobs/ Share on other sites More sharing options...
ridiculous Posted October 2, 2006 Author Share Posted October 2, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/22812-brilliant-minds-tackle-this-warning-missing-argument-1-for-display_jobs/#findComment-102763 Share on other sites More sharing options...
tleisher Posted October 2, 2006 Share Posted October 2, 2006 "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. Quote Link to comment https://forums.phpfreaks.com/topic/22812-brilliant-minds-tackle-this-warning-missing-argument-1-for-display_jobs/#findComment-102764 Share on other sites More sharing options...
ridiculous Posted October 3, 2006 Author Share Posted October 3, 2006 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!!! Quote Link to comment https://forums.phpfreaks.com/topic/22812-brilliant-minds-tackle-this-warning-missing-argument-1-for-display_jobs/#findComment-102773 Share on other sites More sharing options...
ridiculous Posted October 3, 2006 Author Share Posted October 3, 2006 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><?} Quote Link to comment https://forums.phpfreaks.com/topic/22812-brilliant-minds-tackle-this-warning-missing-argument-1-for-display_jobs/#findComment-102788 Share on other sites More sharing options...
Fehnris Posted October 4, 2006 Share Posted October 4, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/22812-brilliant-minds-tackle-this-warning-missing-argument-1-for-display_jobs/#findComment-103474 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.