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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.