Page 1 of 2

NEWS funktion problem.....

Posted: Mon Jun 10, 2002 11:40 am
by HG
I have a problem... if annyone can solve it plez let me now...

Code: Select all

Notice: Use of undefined constant localhost - assumed 'localhost' in D:\webb\hgtwo\news\db.inc.php on line 6

Notice: Use of undefined constant root - assumed 'root' in D:\webb\hgtwo\news\db.inc.php on line 7

Notice: Use of undefined constant hg - assumed 'hg' in D:\webb\hgtwo\news\db.inc.php on line 8

Notice: Use of undefined constant hgnews - assumed 'hgnews' in D:\webb\hgtwo\news\db.inc.php on line 9

Notice: Use of undefined constant admin - assumed 'admin' in D:\webb\hgtwo\news\db.inc.php on line 10

Notice: Use of undefined constant groups - assumed 'groups' in D:\webb\hgtwo\news\db.inc.php on line 11

Notice: Use of undefined constant news - assumed 'news' in D:\webb\hgtwo\news\db.inc.php on line 12

Notice: Use of undefined constant news_comments - assumed 'news_comments' in D:\webb\hgtwo\news\db.inc.php on line 13

Notice: Use of undefined constant news_logged - assumed 'news_logged' in D:\webb\hgtwo\news\db.inc.php on line 14

Notice: Use of undefined constant partners - assumed 'partners' in D:\webb\hgtwo\news\db.inc.php on line 15

Notice: Use of undefined constant pnews - assumed 'pnews' in D:\webb\hgtwo\news\db.inc.php on line 16

Notice: Use of undefined constant smileys - assumed 'smileys' in D:\webb\hgtwo\news\db.inc.php on line 17

Notice: Use of undefined constant topic - assumed 'topic' in D:\webb\hgtwo\news\db.inc.php on line 18

Notice: Use of undefined constant users - assumed 'users' in D:\webb\hgtwo\news\db.inc.php on line 19

Notice: Use of undefined constant weekQ - assumed 'weekQ' in D:\webb\hgtwo\news\db.inc.php on line 20

Notice: Use of undefined constant WeekA - assumed 'WeekA' in D:\webb\hgtwo\news\db.inc.php on line 21
this is my problem in the news funktion...

Code: Select all

Notice: Undefined index: do_what in D:\webb\crookz\guestbook\sign.php on line 8

Notice: Undefined index: action in D:\webb\crookz\guestbook\sign.php on line 33
this is the problem in the guestbook


plez help me!!!!!! 8O

Posted: Mon Jun 10, 2002 12:03 pm
by twigletmac
Looks like you might have arrays where you've got,

Code: Select all

$arrayїtext]
or loop conditionals like

Code: Select all

if ($this == something) {
If you have try changing these to something like

Code: Select all

$arrayї'text']
if ($this == 'something') {
And you may also be needing to read this

Although I can't say anything for sure without seeing any code...

Mac

ok..

Posted: Mon Jun 10, 2002 2:38 pm
by HG
thx... here is the code... I´m a newbi...

Code: Select all

<?
$db_server = localhost;
$db_uname  = root;
$db_pass   = hg;
$db_name   = hgnews;
$db_admin  = admin;
$db_groups = groups;
$db_news   = news;
$db_news_comments = news_comments;
$db_news_logged = news_logged;
$db_partners = partners;
$db_pnews  = pnews;
$db_smileys = smileys;
$db_topic  = topic;
$db_users  = users;
$db_weekQ  = weekQ;
$db_weekA  = WeekA;
$smileys_path  = "D:\\webb\\hgtwo\\news/gfx/smileys";
$partners_path = "D:\\webb\\hgtwo\\news/gfx/partners";
$topic_path = "D:\\webb\\hgtwo\\news/topic";
$topic_url = "./topic";
$smiley_url = "./gfx/smileys/";
$partners_url = "./gfx/partners/";
?>
hope this cane help you help me some moor.. :D

Posted: Mon Jun 10, 2002 4:04 pm
by volka
jo, no quoting.
$db_server = localhost -> $db_server = 'localhost' and so on
like $smileys_path = "D:\\webb\\hgtwo\\news/gfx/smileys";
when using "string" variables are parsed i.e.
print("path is $smileys_path");
path is D:\webb\hgtwo\news/gfx/smileys
will be printed
print('path is $smileys_path'); // no replacement
path is $smileys_path
btw. mixing \ and / in paths.....hmmm

Posted: Tue Jun 11, 2002 2:06 am
by mikeq
Try puting quotes around the values being assigned to the variables

<?
$db_server = 'localhost';
$db_uname = 'root';
$db_pass = 'hg';
...

without puting the quotes the php interpreter doesn't know they are strings and assumes they are CONSTANTS (look up php.net), but because you haven't defined any constants you get the error messages.

Mike

Posted: Tue Jun 11, 2002 2:16 am
by twigletmac
BTW, these errors are just notices which means that they don't stop the code from running, in fact you could change the level of error reporting and never see them. However, PHP would then be doing a lot of work that it doesn't need to, ie. looking for constants that don't exist and then assuming them strings so best to leave it as it is so you can sort these probs.

A good rule of thumb would be to enclose anything that's not just numbers in quotes, eg,

Code: Select all

$var1 = 'hello';
$var2 = '10%';
$var3 = 23;
$var4 = 6.4;
PHP is loosely typed which means that the following:

Code: Select all

$var1 = 12; // an integer
$var2 = '4'; // a string
$result = $var1 - $var2; // $result = 8
will work fine.

Mac

Posted: Tue Jun 11, 2002 2:19 am
by volka
$result = $var1 - $var2; // $result = 8
pro and con of php in one line ;)

Posted: Tue Jun 11, 2002 2:22 am
by twigletmac
Yup, great while you're learning but very easy to get into bad habits :roll: .
Nice not having to worry about type-mismatch errors though.

Mac

just another problem

Posted: Tue Jun 11, 2002 3:56 am
by HG
THX every one... this worked out fine... but now I get a nother Notice
Undefined offset: 1 in D:\webb\hgtwo\news\header.php on line 23
this is the line

Code: Select all

$mpass  = $info&#1111;1];
have no idé how to fix this... plz one more helping hand... :lol:

Posted: Tue Jun 11, 2002 4:02 am
by twigletmac
Basically $info[1] has not been set and therefore you can't access it because it doesn't exist.

If you're trying to access the first element in an array remember that PHP starts at zero when indexing an array so,

Code: Select all

$info = array('foo', 'bar');
echo $info&#1111;0]; // prints foo
echo $info&#1111;1]; // prints bar
Of course we can only guess at what's going wrong if you don't show any code...

Mac

okej,,, sorry

Posted: Tue Jun 11, 2002 4:12 am
by HG
here is the code

Code: Select all

<?php
  //******************************************************************************************
  //**                                                                                      **
  //** phpNewsManager v1.30                                                                 **
  //** contact: gregor@klevze.si                                                            **
  //** Last edited: 27th.May,2002                                                           **
  //******************************************************************************************
 
function CheckLogin()
&#123;
  global $db_admin,$db_news,$db_news_comments,$db_news_logged,$db_partners,$db_pnews,$db_smiles,$db_topic,$db_users,$db_weekQ,$db_weekA;
  global $nm_user,$action,$login,$pass;
  $info = base64_decode("$nm_user");
  $info = explode(":", $info);
  if ($action == "Login")
   &#123;
    global $login,$pass;
    $info&#1111;0] = $login;
    $info&#1111;1] = $pass;
   &#125;

  $mlogin = $info&#1111;0];
  $mpass  = $info&#1111;1];
  $result = mysql_query("select passwd from $db_admin where uname='$mlogin'") or die ("<B>Error 2:</B> Invalid query");
  $passek = 0;
  if(mysql_num_rows($result)==1) 
   &#123;
    $ar = mysql_fetch_array($result);
    if ($ar&#1111;passwd] == $mpass) &#123;$passek=1;&#125; 
   &#125;
  if ($mlogin == "") &#123;$passek=0;&#125;
  return $passek;
&#125;

function ShowLogin()
&#123; 
 global $color05;
 global $db_admin,$db_news,$db_news_comments,$db_news_logged,$db_partners,$db_pnews,$db_smiles,$db_topic,$db_users,$db_weekQ,$db_weekA;
 ?>
 <FORM ACTION="login.php" METHOD=POST>
 <FONT COLOR=#<?echo $color05;?>>Login</FONT><BR>
 <INPUT TYPE="text" NAME="login" SIZE=12 MAXLENGTH=40><BR>
 Password<BR><INPUT TYPE="password" NAME="pass" SIZE=12 MAXLENGTH=40>
 <INPUT TYPE="submit" Value="login"><BR>
 <INPUT TYPE="hidden" NAME="action" VALUE="login"><BR>
 </FORM> <?
&#125;


?>
<TABLE WIDTH="796" CELLSPACING=0 CELLPADDING=0 BORDER=0 HEIGHT=65>
 <TR>
  <TD CLASS=MojText BGCOLOR=#<?echo $color02;?>>
   <A HREF="index.php"><IMG SRC="<?echo $logo;?>" BORDER=0 WIDTH=280 HEIGHT=65></A><BR>
  </TD>
  <TD BGCOLOR=#<?echo $color02;?> VALIGN=BOTTOM ALIGN=RIGHT>
   <FONT SIZE=4 COLOR=#<?echo $color03;?> FACE=Tahoma>WEB CONTROL PANEL</FONT> 
  </TD>
 </TR>
 <TR>
  <TD COLSPAN=2 HEIGHT=1 BGCOLOR=#<?echo $color01;?>>
  </TD>
 </TR>
 <TR><TD COLSPAN=2 HEIGHT=2 BGCOLOR=#<?echo $color01;?>></TD></TR>
</TABLE>

<TABLE border=0 WIDTH="795" HEIGHT=100% CELLSPACING=0 CELLPADDING=1 BORDER=0 BACKGROUND="/gfx/tile.gif">
 <TR>
  <TD WIDTH=180 VALIGN=TOP Class=MojText BGCOLOR=#FFFFFF>
   <TABLE WIDTH=150 ALIGN=CENTER CELLSPACING=1 CELLPADDING=0 CLASS=MojText>
    <TR>
     <TD COLSPAN=2 Class=MojHead>
      User Information
     </TD>
    </TR>
    <TR>
     <TD CLASS=BoxText>
      <?
      $psw = CheckLogin();
      $info = base64_decode("$nm_user");
      $info = explode(":", $info);
      if ($action=="Login") &#123; $info&#1111;0]=$login;&#125;      
      $login = $info&#1111;0];
      if ($psw == 0) &#123; ShowLogin();&#125;
      else
       &#123;
        $res = mysql_query("SELECT * from $db_admin where uname='$login'");
        $ar = mysql_fetch_array($res);
        echo "Username: <B>".$ar&#1111;uname]."</B><BR>";
	?>
	<A HREF="index.php?action=Logout"><IMG SRC="./gfx/logout.jpg" BORDER=0 ALT="Logout"></A><?
       &#125;
      ?>
     </TD>
    </TR>
   </TABLE>
   <BR><BR>
   <?if ($psw <> 0) &#123; 
   ?>
   <TABLE WIDTH=90% ALIGN=CENTER CELLSPACING=1 CELLPADDING=0 CLASS=MojText BGCOLOR=#<?echo $color03;?>>
    <TR BGCOLOR=#<?echo $color02;?>>
     <TD COLSPAN=2 Class=MojHead>
      <FONT COLOR=#<?echo $color05;?>>Manager</FONT>
     </TD>
    </TR>
    <TR BGCOLOR=#<?echo $color04;?>>
     <TD CLASS=BoxText>
      <A HREF="index.php"><IMG SRC="gfx/docman.gif" BORDER=0 ALT="Modify News">Main</A><BR>
      <A HREF="news.php"><IMG SRC="gfx/docman.gif" BORDER=0 ALT="Modify News">News</A><BR>
      <A HREF="groups.php"><IMG SRC="gfx/docman.gif" BORDER=0 ALT="Modify News">Groups</A><BR>
      <A HREF="admin.php"><IMG SRC="gfx/docman.gif" BORDER=0 ALT="Modify categories">Admin's</A><BR>
      <A HREF="pnews.php"><IMG SRC="gfx/docman.gif" BORDER=0 ALT="Modify Public News">Public News</A><BR>
      <A HREF="category.php"><IMG SRC="gfx/docman.gif" BORDER=0 ALT="Modify categories">Category</A><BR>
      <A HREF="user.php"><IMG SRC="gfx/docman.gif" BORDER=0 ALT="Modify categories">Users</A><BR>
      <A HREF="partners.php"><IMG SRC="gfx/docman.gif" BORDER=0 ALT="Modify partners">Partners</A><BR>
      <A HREF="poll.php"><IMG SRC="gfx/docman.gif" BORDER=0 ALT="Weekly Poll">Weekly Poll</A><BR>
      <A HREF="smileys.php"><IMG SRC="gfx/docman.gif" BORDER=0 ALT="Smileys">Smileys</A><BR>
      <BR>
      <A HREF="browse.php"><IMG SRC="gfx/docman.gif" BORDER=0 ALT="Watch news">Browse News</A><BR>
      <BR>
     </TD>
    </TR>
   </TABLE>
   <?
   &#125;?>
  </TD>
  <TD WIDTH=1 VALIGN=TOP Class=mojText BGCOLOR=#000000>
  <TD WIDTH=100% VALIGN=TOP Class=mojText BGCOLOR=#<?echo $color06;?>>

Posted: Tue Jun 11, 2002 4:51 am
by twigletmac
Try changing this,

Code: Select all

if ($action == "Login") &#123; 
    global $login,$pass; 
    $info&#1111;0] = $login; 
    $info&#1111;1] = $pass; 
&#125;
to something like this,

Code: Select all

$info&#1111;0] = '';
$info&#1111;1] = '';
if (isset($_POST&#1111;'action']) && $_POST&#1111;'action'] == 'Login') &#123; 
    $info&#1111;0] = $_POST&#1111;'login']; 
    $info&#1111;1] = $_POST&#1111;'pass']; 
&#125;
and

Code: Select all

if ($action=="Login") &#123; $info&#1111;0]=$login;&#125;      
$login = $info&#1111;0];
to something like

Code: Select all

if (isset($_POST&#1111;'action']) && $_POST&#1111;'action'] == 'Login') &#123; 
    $info&#1111;0] = $_POST&#1111;'login'];
&#125; else &#123;
    $info&#1111;0] = '';
&#125;
$login = $info&#1111;0];
This should explain why you need to make these changes.

Mac

this dident work..

Posted: Tue Jun 11, 2002 5:40 am
by HG
Parse error: parse error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in D:\webb\hgtwo\news\header.php on line 18
this is the error I get now.... ?

sorry if I´m stupid HG

Posted: Tue Jun 11, 2002 5:44 am
by twigletmac
:oops: Forgot a closing parenthesis - amended the code above see if trying it again is any better.

Mac

Posted: Tue Jun 11, 2002 5:57 am
by HG
okej... now I´m back to same problem again as before... hmm :oops:
Notice: Undefined offset: 1 in D:\webb\hgtwo\news\header.php on line 24