mdshare Posted March 28, 2007 Share Posted March 28, 2007 $res = mysql_query("SELECT * FROM village"); if ($res) { while ($newarray = mysql_fetch_array($res, mysql_assoc)) { $id = $newarray['id']; $vname = $newarray['name']; $vplayer = $newarray['player']; echo "the id of the village is ".$id." its name is ".$vname." the owner is ".$vplayer." "; } } else { printf("failed: %s\n", mysql_error($mysql)); } this isn't a script of mine but we have looked 1h to find the error in this small script, the error is the famous Warning: mysql_fetch_array missing argument thingy the solution is actually very simple (deception already knows so refrain from posting please) so lets see who can find it faster than we did Quote Link to comment Share on other sites More sharing options...
kronow Posted March 28, 2007 Share Posted March 28, 2007 Re: 1h work to solve the dumbest error there is is the connection to the database working? anything to do with the newarray's? and why use while statments? Quote Link to comment Share on other sites More sharing options...
mdshare Posted March 28, 2007 Author Share Posted March 28, 2007 Re: 1h work to solve the dumbest error there is it all works and really, it's a easy overlooked error something to remember when discoverd another part of the code so that you see the stuff before it mysql_connect($hostname,$username,$passwd)or die("cannot connect to db:".mysql_error()); mysql_select_db($db_name) or die (mysql_error()); mysql_query("drop table village"); mysql_query(" create table village( id int primary key, name varchar(75), x int, y int, player int, points int, rank int)"); $lines = gzfile('http://www.domain.com/x/update.txt.gz', 'r'); if(!is_array($lines)) die("File could not be opened"); foreach($lines as $line) { list($id, $name,$x, $y, $player, $points, $rank) = explode(',', $line); $name = urldecode($name); $name = addslashes($name); mysql_query("INSERT INTO village SET id='$id', name='$name', x='$x', y='$y', player='$player', points='$points', rank='$rank'"); } Quote Link to comment Share on other sites More sharing options...
Cronus Posted April 15, 2007 Share Posted April 15, 2007 Re: 1h work to solve the dumbest error there is This: $res = mysql_query("SELECT * FROM village"); Should be this: $res = mysql_query("SELECT * FROM village",$c); That's my guess. Quote Link to comment Share on other sites More sharing options...
mdshare Posted April 15, 2007 Author Share Posted April 15, 2007 Re: 1h work to solve the dumbest error there is nah mySQL commands have to be uppercase so mysql_assoc had to be put upper case and it worked perfect Quote Link to comment Share on other sites More sharing options...
Mambug Posted May 3, 2007 Share Posted May 3, 2007 Re: 1h work to solve the dumbest error there is mySQL commands have to be uppercase No they don't. They are recommended to be uppercase as an easier way to recognize the MySQL syntax from regular variables. Now, the variables themself are case-sensitive. Quote Link to comment Share on other sites More sharing options...
stryker Posted May 15, 2007 Share Posted May 15, 2007 Re: 1h work to solve the dumbest error there is i agree Quote Link to comment Share on other sites More sharing options...
stryker Posted June 17, 2007 Share Posted June 17, 2007 Re: 1h work to solve the dumbest error there is but lets see if you can fix this? Warning: Wrong parameter count for mysql_fetch_assoc() in past.php on line 41 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in past.php on line 49 lines 38 - 49 $prize = array(); $query = sprintf("SELECT rank,prize FROM prizes WHERE type = 'supporter'"); $prizeResult = mysql_query($query); while($line = mysql_fetch_array($prizeResult)){ $prize[$line[0]] = $line[1]; } $query = sprintf("SELECT id,pimp,networth,online,rank,nrank,status,online FROM %s WHERE status='supporter' ORDER BY nrank ASC limit 10", $pTable); //echo $query; $supResult = mysql_query($query); $i = 1; while($line = mysql_fetch_assoc($supResult,MYSQL_ASSOC)){ if($rankstart==0){$rankcolor="#220000";$rankstart++;} Quote Link to comment Share on other sites More sharing options...
Decepti0n Posted June 17, 2007 Share Posted June 17, 2007 Re: 1h work to solve the dumbest error there is while($line = mysql_fetch_assoc($supResult, MYSQL_ASSOC)){ to while($line = mysql_fetch_assoc($supResult)){ mysql_fetch_assoc is the same as mysql_fetch_array($query, MYSQL_ASSOC) Quote Link to comment Share on other sites More sharing options...
stryker Posted June 17, 2007 Share Posted June 17, 2007 Re: 1h work to solve the dumbest error there is now i a getting Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in past.php on line 49 line 49 while($line = mysql_fetch_array($supResult,MYSQL_ASSOC)){ Quote Link to comment Share on other sites More sharing options...
Decepti0n Posted June 17, 2007 Share Posted June 17, 2007 Re: 1h work to solve the dumbest error there is Normally, that happens when I don't return any rows, try using mysql_num_rows() to see if it returns anything, otherwise you'll have to change the query, or add some data in Quote Link to comment Share on other sites More sharing options...
waffles Posted June 27, 2007 Share Posted June 27, 2007 Re: 1h work to solve the dumbest error there is $query = sprintf("SELECT rank,prize FROM prizes WHERE type = 'supporter'"); change to $query = sprintf("SELECT rank,prize FROM prizes WHERE type=supporter") AND $prizeResult = mysql_query($query); change to $prizeResult = mysql_query($query) or die(mysql_error()); That will tell you exactly what is wrong with the query. It was made for a reason, to make debugging faster. Quote Link to comment Share on other sites More sharing options...
Redeye Posted February 4, 2008 Share Posted February 4, 2008 Re: 1h work to solve the dumbest error there is $res = mysql_query("SELECT * FROM village"); if ($res) { while ($newarray = mysql_fetch_array($res, mysql_assoc)) { $id = $newarray['id']; $vname = $newarray['name']; $vplayer = $newarray['player']; echo "the id of the village is ".$id." its name is ".$vname." the owner is ".$vplayer." "; } } else { printf("failed: %s\n", mysql_error($mysql)); } this isn't a script of mine but we have looked 1h to find the error in this small script, the error is the famous Warning: mysql_fetch_array missing argument thingy the solution is actually very simple (deception already knows so refrain from posting please) so lets see who can find it faster than we did Is it this printf("failed: %s\n", mysql_error($mysql)); but it should be print("failed: %s\n", mysql_error($mysql)); ???? Quote Link to comment 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.