TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-05-2008, 12:57 AM   #1 (permalink)
The Contributor
 
pipesportugal's Avatar
 
Join Date: May 2008
Location: Oporto-Portugal
Posts: 32
Thanks: 11
pipesportugal is on a distinguished road
Default Fatal error: [] operator not supported for strings in /....

Hello there,

I started getting this message out of nothing.
Well, I've changed the hosting server for the website.

I already made many many tests and none of them sucessfull in order to solve this problem.

Can someone help, please?

This is the code:
===========================
include("include/dbconnect.php");
$query = "SELECT * FROM tabela_vendedores";
$result = mysql_query($query, $db);
while ($row = mysql_fetch_array($result))
{
$cod_vendedor[] = $row['cod_vendedor'];
$nome_vendedor[] = $row['nome_vendedor'];
}
===========================
pipesportugal

Last edited by pipesportugal : 06-05-2008 at 12:59 AM. Reason: mistake
pipesportugal is offline  
Reply With Quote
Old 06-05-2008, 01:32 AM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

The problem seems to have something to do with PHP assuming you're assigning an array reference to a string - I don't know if this will work, but what if you tried initializing the two arrays before using them in the while loop?

PHP Code:
$cod_vendedor = array();
$nome_vendedor = array(); 
If just adding that doesn't work, maybe initialize them and then try this?

PHP Code:
while($row mysql_fetch_array($result))
{
array_push($cod_vendedor$row['cod_vendedor']);
array_push($nome_vendedor$row['nome_vendedor']);

Is your new host running a newer version of PHP than your old host was? The only reason [] shouldn't work is if it thinks you're trying to assign an array value to something that's already been set as a string, or if it's somehow causing duplicate key names, from what I gather.
-m
delayedinsanity is offline  
Reply With Quote
The Following User Says Thank You to delayedinsanity For This Useful Post:
pipesportugal (06-05-2008)
Old 06-05-2008, 10:00 PM   #3 (permalink)
The Contributor
 
pipesportugal's Avatar
 
Join Date: May 2008
Location: Oporto-Portugal
Posts: 32
Thanks: 11
pipesportugal is on a distinguished road
Default

Hi delayedinsanity,

I initialized the 2 arrays as per Your first suggestion and it solved the problem right away.

I guess that somehow I must have used this variables somewhere back (I did not go and check...) because there are a lot of includes and this subroutine was also an include itself.

I think the most important here is that the problem is solved.

I appreciated Your help. Thank You.
pipesportugal
pipesportugal is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:34 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design