Monday 15 April 2013

getting warning while fetching rows from mysql using php -


This is a duplicate question, but I tried all the answers, which have already been posted.

This is my code

  Include "db.php"; // $ poster_id = 1; $ Sql ​​= "pi.forl_name, pi.poster_img, pi.poster_tag, p.post_title, p.post_description, p.post_tag, p.post_snap's post p selected p.poster_id = pi.auth_id POSTER_INFO join exemplary"; $ Result = mysql_query ($ sql) or die (mysql_error ()); Echo mysql_error (); $ Msg = ""; While ($ line = mysql_fetch_array ($ result)) {$ msg_footer = "& lt; div class = 'post_footer' & gt;"; $ Msg_footer = $ msg_Footer. "& Lt; div class = 'post_img' & gt;"; $ Msg_power = $ msg_fruit. "& Lt; img src = '". 'Data: Image / JPEG; Base 64, '. Base64_encode ($ line [6]). '' Width = '330' height = '130' /> & Lt; / Div & gt; "; $ Msg_footer = $ msg_footer." & Lt; Div class = 'post_author' & gt; & Lt; Div class = 'author_img' & gt; & Lt; Img src = '".' Data: Image / JPEG; Base64, 'Base64_encode ($ line [1])."' Width = '80' height = '80' /> & Lt; / Div> "; $ Msg_footer = $ msg_piler." & Lt; Div class = 'author_info' & gt; & Lt; B & gt; "$ line [0]." & Lt; / B & gt; & Lt; Br / & gt; & Lt; Span style = 'font-size: 11px' & gt; "from $ line [2]" & lt; / Span & gt; & Lt; Br / & gt; & Lt; Span style = 'font-size: 10px' & Gt; Post 1 & lt; / Span & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; "; $ Msg. =" & Lt; Li & gt; & Lt; Br / & gt; & Lt; Span class = 'post_title' & gt; ". $ Line [3]." & Lt; / Span & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Span class = 'post_description' & gt; ". $ Line [4]" to & lt; / Span & gt; & Lt; / Li & gt; "; $ Msg. = $ Msg_Footer; // warning for this line // pointing to warning}   

I'm getting the warning, which is the last line of the loop Pointing to;

  Warning: mysql_fetch_array () parameter expected 1 source, boolean is given at C: \ xampp \ htdocs \ labs \ load_data.php on line 40   

My SQL query is correct because, I tried to execute it in the SQL Editor and in the PHP page like this

   gt; & lt; gt; & lt; php echo $ line [2];? & Gt; & lt ; / TD> gt; & lt; td & gt; & lt ;? Php echo $ line [3]; ? & Gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt ;? Php}? & Gt;   

In this case, I can not find any warning.

I'm pretty sure that the code you posted has not started an error.


Check the return value on all the positions in the code , like this:

  if (mysql_query (...) = == incorrect) {dead (mysql_error ()); }   

I think you are already doing that code that you have shown, but I think the warning will start at the second point of the code.


There may be another explanation, that you can overwrite $ result from anywhere in the code - but it has not been shown properly.


General advice : Do not use the mysql _ * function for the new code. They dislikely use PDO or mysqli _ * instead of

No comments:

Post a Comment