I have a web page that prints information from a database based on the query string variables. Sometimes the page loads just fine and other times it gives the message "Use of uninitialized value" for every single one of my database variables. The times it gives this message seem to be when there is info in the Description, Steps, and/or WorkAround fields, all of which are memos.

Is there something I'm doing wrong or missing from this code? do you need to see more of it? or can you think of something else I should check if the code looks fine?

$bugID = $in{'ID'};
$user = $in{'user'};

### connect to database #####
$dbhandle = DBI->connect("DBI:ODBC:bugzdead") or &errorPage("Couldn't connect to database: " . DBI->errstr());

### get bug info #####
$sql = "SELECT B.Problem, B.Product, B.Version, B.Type, B.Severity, B.Description, B.Steps, B.WorkAround, B.SubmittedBy, S.Status, S.DateSubmitted, S.DateEdited, R.AverageRating FROM Bugs AS B, Status AS S, Rating AS R WHERE B.ID=S.BugID AND S.BugID=R.BugID AND ID=" . $bugID;
$query = $dbhandle->prepare($sql) or &errorPage("Couldn't prepare Select Bug Info query: " . $dbhandle->errstr());
$query->execute() or &errorPage("Couldn't execute Select Bug Info query: " . $query->errstr());

@row = $query->fetchrow_array();

### database variables #####
$problem = $row[0];
$product = $row[1];
$version = $row[2];
$type = $row[3];
$severity = $row[4];
$description = $row[5];
$steps = $row[6];
$workAround = $row[7];
$submittedBy = $row[8];
$status = $row[9];
$dateSubmitted = $row[10];
$dateEdited = $row[11];
$averageRating = $row[12];
9 Years
Discussion Span
Last Post by katharnakh

You might want to assign values if your [inline]@row[/inline] has something. Though, sometimes query executes fine and returns nothing your [inline]@row[/inline] will be an empty array.

@row = $query->fetchrow_array();
if (scalar(@row) > 0){
# code to assign other variables from @row.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.