Jump to content

Stupid PHP Problem


Inferno_str1ke

Recommended Posts

Ok, simple thing, I have the following lines:
[CODE]
$query="SELECT * FROM ".$L_sqlprefix."config";
$result=mysql_query($query) OR die($query.'<br/>'.mysql_error());
while ($line=mysql_fetch_array($result,MYSQL_ASSOC))
{
$_[ $line['title'] ] = $line['value'];
}
[/CODE]
What this does is take a title and value out of the database and stick it into an array. When printed ( print_r($_); ) the array should look like this:
[CODE]
Array (
[blogtitle] => 1.k.e.Net
[thisurl] => http://127.0.0.1:85/
[feedurl] => rss.php
[feedtype] => RSS 2.0
[install] => complete )
[/CODE]
When executing on my test server the code performs fine, but when I run it on my web server the array comes out as follows:
[CODE]
Array (
[blogtitle] => 1
[thisurl] => h
[feedurl] => r
[feedtype] => R
[install] => c )
[/CODE]
Which is obviously useless to me. Now I'm stumped as to why it's behaving differently in different locations, and also stumped as to another way to get the info into an array.

I've tried a a few different ways on the web server, all produce random and useless results:
[CODE]
array ($_);
$query="SELECT * FROM config";
$result=mysql_query($query) OR die($query.'<br/>'.mysql_error());
while ($line=mysql_fetch_array($result,MYSQL_ASSOC))
{
$_[$line['title']]=$line['value'];
echo $line['title'].'<br/>';
echo $line['value'].'<br/>';
print_r($_);
echo '<br/><br/>';
}
[/CODE]
Result:
[CODE]blogtitle
1keNet
1usr/local/apache/bin/httpd

thisurl
http://127.0.0.1:85/
husr/local/apache/bin/httpd

feedtype
RSS 2.0
Rusr/local/apache/bin/httpd

perpage
10
1usr/local/apache/bin/httpd[/CODE]
There are more but I've cut it short and you get the point. Incidentally using:
[CODE]$array=mysql_fetch_array($result,MYSQL_ASSOC);
foreach ($array as $subarray)
{
echo $subarray.'<br/><br/>';
}[/CODE]
instead of the While loop gives me the result (not cut short):
[CODE]1

blogtitle

1keNet

0[/CODE]
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.