PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
HG
Forum Newbie
Posts: 18 Joined: Mon Jun 10, 2002 11:40 am
Location: sweden
Contact:
Post
by HG » Mon Jun 10, 2002 11:40 am
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!!!!!!
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Mon Jun 10, 2002 12:03 pm
Looks like you might have arrays where you've got,
or loop conditionals like
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
HG
Forum Newbie
Posts: 18 Joined: Mon Jun 10, 2002 11:40 am
Location: sweden
Contact:
Post
by HG » Mon Jun 10, 2002 2:38 pm
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..
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Mon Jun 10, 2002 4:04 pm
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
mikeq
Forum Regular
Posts: 512 Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland
Post
by mikeq » Tue Jun 11, 2002 2:06 am
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
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Tue Jun 11, 2002 2:16 am
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
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Tue Jun 11, 2002 2:19 am
$result = $var1 - $var2; // $result = 8
pro and con of php in one line
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Tue Jun 11, 2002 2:22 am
Yup, great while you're learning but very easy to get into bad habits
.
Nice not having to worry about type-mismatch errors though.
Mac
HG
Forum Newbie
Posts: 18 Joined: Mon Jun 10, 2002 11:40 am
Location: sweden
Contact:
Post
by HG » Tue Jun 11, 2002 3:56 am
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
have no idé how to fix this... plz one more helping hand...
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Tue Jun 11, 2002 4:02 am
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ї0]; // prints foo
echo $infoї1]; // prints bar
Of course we can only guess at what's going wrong if you don't show any code...
Mac
HG
Forum Newbie
Posts: 18 Joined: Mon Jun 10, 2002 11:40 am
Location: sweden
Contact:
Post
by HG » Tue Jun 11, 2002 4:12 am
here is the code
Code: Select all
<?php
//******************************************************************************************
//** **
//** phpNewsManager v1.30 **
//** contact: gregor@klevze.si **
//** Last edited: 27th.May,2002 **
//******************************************************************************************
function CheckLogin()
{
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")
{
global $login,$pass;
$infoї0] = $login;
$infoї1] = $pass;
}
$mlogin = $infoї0];
$mpass = $infoї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)
{
$ar = mysql_fetch_array($result);
if ($arїpasswd] == $mpass) {$passek=1;}
}
if ($mlogin == "") {$passek=0;}
return $passek;
}
function ShowLogin()
{
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> <?
}
?>
<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") { $infoї0]=$login;}
$login = $infoї0];
if ($psw == 0) { ShowLogin();}
else
{
$res = mysql_query("SELECT * from $db_admin where uname='$login'");
$ar = mysql_fetch_array($res);
echo "Username: <B>".$arїuname]."</B><BR>";
?>
<A HREF="index.php?action=Logout"><IMG SRC="./gfx/logout.jpg" BORDER=0 ALT="Logout"></A><?
}
?>
</TD>
</TR>
</TABLE>
<BR><BR>
<?if ($psw <> 0) {
?>
<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>
<?
}?>
</TD>
<TD WIDTH=1 VALIGN=TOP Class=mojText BGCOLOR=#000000>
<TD WIDTH=100% VALIGN=TOP Class=mojText BGCOLOR=#<?echo $color06;?>>
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Tue Jun 11, 2002 4:51 am
Try changing this,
Code: Select all
if ($action == "Login") {
global $login,$pass;
$infoї0] = $login;
$infoї1] = $pass;
}
to something like this,
Code: Select all
$infoї0] = '';
$infoї1] = '';
if (isset($_POSTї'action']) && $_POSTї'action'] == 'Login') {
$infoї0] = $_POSTї'login'];
$infoї1] = $_POSTї'pass'];
}
and
Code: Select all
if ($action=="Login") { $infoї0]=$login;}
$login = $infoї0];
to something like
Code: Select all
if (isset($_POSTї'action']) && $_POSTї'action'] == 'Login') {
$infoї0] = $_POSTї'login'];
} else {
$infoї0] = '';
}
$login = $infoї0];
This should explain why you need to make these changes.
Mac
Last edited by
twigletmac on Tue Jun 11, 2002 5:58 am, edited 2 times in total.
HG
Forum Newbie
Posts: 18 Joined: Mon Jun 10, 2002 11:40 am
Location: sweden
Contact:
Post
by HG » Tue Jun 11, 2002 5:40 am
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
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Tue Jun 11, 2002 5:44 am
Forgot a closing parenthesis - amended the code above see if trying it again is any better.
Mac
HG
Forum Newbie
Posts: 18 Joined: Mon Jun 10, 2002 11:40 am
Location: sweden
Contact:
Post
by HG » Tue Jun 11, 2002 5:57 am
okej... now I´m back to same problem again as before... hmm
Notice: Undefined offset: 1 in D:\webb\hgtwo\news\header.php on line 24
Last edited by
HG on Tue Jun 11, 2002 6:02 am, edited 1 time in total.