Jump to content

Recommended Posts

Fatal error: [] operator not supported for strings in /path/to/files on line 13 (get the same for line 14)

 

 

Here is the code.

<?php

$query="SELECT question, answer, date as d FROM jotd, jokes WHERE jotd.jokeid = jokes.jokeid";
$result=mysql_query($query);
while($row=mysql_fetch_object($result))
{
$date[]=$row->d;
$question[]=$row->question; // line 13
$answer[]=$row->answer;  // line 14
}

?>

 

It don't bitch about the $date[] part which is a unix time stamp, but it don't like the question or answer for this joke archive script.

 

I have run into this before and just said F*$K it and moved on to a different way to accomplish it, but this time I would like to understand what the hell is going on here.

 

THanks for your help.

 

Nathan

 

same

 

new code

<?php 

$query="SELECT question, answer, date as d FROM jotd, jokes WHERE jotd.jokeid = jokes.jokeid";
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
{
$date[]=$row['d'];
$question[]=$row['question'];
$answer[]=$row['answer'];
}

?>

 

The db data type is varchar(255), would that have anything to do with it?

Are $date, $question, or $answer used as string variables previously in your code?

 

That is the problem. I "forgot" that I was using $question  & $answer in my header file which is an included file. I changed them to $q & $a , and all is right with the world :)

 

Thanks, now I know what to look for if I run into this error again.

 

 

much obliged for the help folks.

 

Nate

 

 

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.