dropfaith Posted October 6, 2008 Share Posted October 6, 2008 im lost Notice: Undefined variable: Authors in /home/www/lawrenceguide.org/www/literature/author.php on line 60 Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/www/lawrenceguide.org/www/literature/author.php on line 60 <?php // includes include("../template/conf.php"); // open database connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $genres = array(); $q = "SELECT Author FROM story"; $r = mysql_query($q); while ( $row = mysql_fetch_row($r) ): $add = $row[0]; if ( !in_array($add, $Authors) ): $Authors[] = $add; Endif; Endwhile; $n = count($Authors); for ($i = 0; $i < $n; $i++): $Author = $Authors[$i]; $query = "SELECT id FROM story WHERE Author='$Author' ORDER BY id DESC"; $result = mysql_query($query); $num = mysql_num_rows($result); echo '<tr><td><a href="byauthor.php?Author=' . $Author . '">' . $Author . '</a> ( ' . $num . ' )</td></tr>'; Endfor; ?> Link to comment https://forums.phpfreaks.com/topic/127309-whats-this-error-mean/ Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 Declare $Authors as an array before your loop. $Authors = array(); Link to comment https://forums.phpfreaks.com/topic/127309-whats-this-error-mean/#findComment-658475 Share on other sites More sharing options...
DarkWater Posted October 6, 2008 Share Posted October 6, 2008 1. You don't have $Authors set, and you try to use it in in_array(), which causes BOTH errors. 2. You need to indent your code. It helps. 3. It's often more readable to use { } instead of if: endif; and the like. Link to comment https://forums.phpfreaks.com/topic/127309-whats-this-error-mean/#findComment-658476 Share on other sites More sharing options...
dropfaith Posted October 6, 2008 Author Share Posted October 6, 2008 solved but i cant see the button to make this solved wierd Link to comment https://forums.phpfreaks.com/topic/127309-whats-this-error-mean/#findComment-658479 Share on other sites More sharing options...
F1Fan Posted October 6, 2008 Share Posted October 6, 2008 solved but i cant see the button to make this solved wierd I have no idea what that means. Link to comment https://forums.phpfreaks.com/topic/127309-whats-this-error-mean/#findComment-658492 Share on other sites More sharing options...
DarkWater Posted October 6, 2008 Share Posted October 6, 2008 Read the post in PHPFreaks site board. They upgraded to SMF2 and now Solved doesn't work. They'll fix it eventually. Link to comment https://forums.phpfreaks.com/topic/127309-whats-this-error-mean/#findComment-658493 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.