Jump to content

[SOLVED] error with simple mysql query


daveh33

Recommended Posts

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???

Link to comment
https://forums.phpfreaks.com/topic/77169-solved-error-with-simple-mysql-query/
Share on other sites

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'];
}

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

 

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'];
}

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

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.