daveh33 Posted November 13, 2007 Share Posted November 13, 2007 if ($free) { $query = mysql_query("SELECT * FROM vids WHERE number='$free'") or die("cant get free vid info"); $row = mysql_fetch_array($query) or die("error with this row"); $videourlfree = $row['videourl']; $imgurlfree = $row['imgurl']; } The code stops and displays the message: error with this row -any ideas??? Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/ Share on other sites More sharing options...
chiprivers Posted November 13, 2007 Share Posted November 13, 2007 What is error? Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390700 Share on other sites More sharing options...
daveh33 Posted November 13, 2007 Author Share Posted November 13, 2007 The page shows: error with this row which is the or die message for $row line Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390702 Share on other sites More sharing options...
rajivgonsalves Posted November 13, 2007 Share Posted November 13, 2007 try and tell me if you see any errors if ($free) { $query = mysql_query("SELECT * FROM vids WHERE number='$free'") or die("cant get free vid info"); $row = mysql_fetch_array($query) or die("error with this row"); if (mysql_error()) { echo mysql_error();} $videourlfree = $row['videourl']; $imgurlfree = $row['imgurl']; } Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390703 Share on other sites More sharing options...
daveh33 Posted November 13, 2007 Author Share Posted November 13, 2007 Exact same error, the screen shows nothing but: error with this row Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390705 Share on other sites More sharing options...
kenrbnsn Posted November 13, 2007 Share Posted November 13, 2007 Change you code to: <?php if ($free) { $query = "SELECT * FROM vids WHERE number='$free'"; $rs = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error()); $row = mysql_fetch_array($rs) or die("error with this row<br>" . mysql_error()); $videourlfree = $row['videourl']; $imgurlfree = $row['imgurl']; }?> This will tell you what the problem is. Ken Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390710 Share on other sites More sharing options...
daveh33 Posted November 13, 2007 Author Share Posted November 13, 2007 I changed that code - it just shows error with this row html source of the page is: error with this row<br> Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390713 Share on other sites More sharing options...
rajivgonsalves Posted November 13, 2007 Share Posted November 13, 2007 why don't you just try something like $row = mysql_fetch_array($rs); Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390714 Share on other sites More sharing options...
kenrbnsn Posted November 13, 2007 Share Posted November 13, 2007 Please repost the code you're using. Ken Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390715 Share on other sites More sharing options...
daveh33 Posted November 13, 2007 Author Share Posted November 13, 2007 if ($free) { $query = "SELECT * FROM vids WHERE number='$free'"; $rs = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error()); $row = mysql_fetch_array($rs) or die("error with this row<br>" . mysql_error()); $videourlfree = $row['videourl']; $imgurlfree = $row['imgurl']; } Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390716 Share on other sites More sharing options...
daveh33 Posted November 13, 2007 Author Share Posted November 13, 2007 why don't you just try something like $row = mysql_fetch_array($rs); I tried this but it doesn't give any values to the below variables $videourlfree = $row['videourl']; $imgurlfree = $row['imgurl']; Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390721 Share on other sites More sharing options...
kenrbnsn Posted November 13, 2007 Share Posted November 13, 2007 Are you sure rows are being returned by the query? Try this: <?php if ($free) { $query = "SELECT * FROM vids WHERE number='$free'"; $rs = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error()); if (mysql_num_rows($rs) > 0) { $row = mysql_fetch_array($rs); $videourlfree = $row['videourl']; $imgurlfree = $row['imgurl']; } else echo 'Problem with the query: ' . $query . '<br>No information returned from the database<br>'; }?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390731 Share on other sites More sharing options...
daveh33 Posted November 13, 2007 Author Share Posted November 13, 2007 Problem with the query: SELECT * FROM vids WHERE number='2147483647' No information returned from the database I do not know where this number has come from - it was inserted into the db as 121333789826 ... strange Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390743 Share on other sites More sharing options...
daveh33 Posted November 13, 2007 Author Share Posted November 13, 2007 Ah .......... its because the number field on the database is set to INT - when I change to VARCHAR it works - thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390744 Share on other sites More sharing options...
toplay Posted November 13, 2007 Share Posted November 13, 2007 Do not double post same topic again. I answered and closed your other one found at: http://www.phpfreaks.com/forums/index.php/topic,167516.0.html Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390746 Share on other sites More sharing options...
daveh33 Posted November 13, 2007 Author Share Posted November 13, 2007 Sorry the page crashed when I submitted and it double posted - theres no way to delete - sorry! Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390752 Share on other sites More sharing options...
revraz Posted November 13, 2007 Share Posted November 13, 2007 The forums have been erroring out the last few days and people think their post didn't go through, so they post again. Do not double post same topic again. I answered and closed your other one found at: http://www.phpfreaks.com/forums/index.php/topic,167516.0.html Quote Link to comment https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/#findComment-390754 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.