Jump to content


Cant read from database


2 replies to this topic

#1 Friiks

    Young Padawan

  • Members
  • Pip
  • 56 posts
  • Gender:Male
  • Location:Latvia
  • Interests:Guitar, music, having all sorts of fun...and well enjoying my life (as enjoyable as it can be) as good as I can :D<br /><br />Oh yea, and of course - http://snowmoons.com

Posted 22 January 2007 - 01:54 PM

Well, yes, sorry bout bothering you guys all the time but yeah, I really want to solve this problem - I made this multi language system but it has to change the content when language is changed also, so I kinda did it but it isn't working.
I tried to echo $l and $lang but they both echoed Array so I'm kinda confused and don't know how to change it.
Here's the code...


Thanks Demonslay, got all the errors fixed and it works just fine ;)

Edited by Friiks, 23 January 2007 - 02:53 PM.


#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 22 January 2007 - 07:28 PM

Have you tried:
var_dump($lang);

That will tell you what's in the array so you can debug and find out what happened.

#3 Friiks

    Young Padawan

  • Members
  • Pip
  • 56 posts
  • Gender:Male
  • Location:Latvia
  • Interests:Guitar, music, having all sorts of fun...and well enjoying my life (as enjoyable as it can be) as good as I can :D<br /><br />Oh yea, and of course - http://snowmoons.com

Posted 23 January 2007 - 02:32 PM

Thanks :D
I realized that I had 2 equal variables but it still doesn't read from the database right =/
this is the problematic part
<?php
$l=$_SESSION['lng'];
//echo $l;
if ($l='lv'){
$result = mysql_query("select * from news WHERE lang='".$l."' AND category='home' order by id desc limit 5");
while($r=mysql_fetch_array($result))
{	  
   $time=$r["time"];
 //  $id=$r["id"];
   $message=$r["message"];
   $title=$r["title"];
	 
 echo '<h3>'.$title.'</h3><br>'.$message.'<br>Ierakstīts - '.$time;
 }}
elseif ($l='eng'){
$result = mysql_query("select * from news WHERE lang='".$l."' AND category='home' order by id desc limit 5");
while($r=mysql_fetch_array($result))
{	  
   $time=$r["time"];
 //  $id=$r["id"];
   $message=$r["message"];
   $title=$r["title"];
	 
 echo '<h3>'.$title.'</h3><br>'.$message.'<br>Posted on - '.$time;}}?>
I echoed $l and it changes correctly but it still isn't reading from database how I want =/

Edited by Friiks, 23 January 2007 - 02:54 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users