need help with some php code in my topsite

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

Post Reply
User avatar
metalhardscripts
Forum Newbie
Posts: 8
Joined: Thu May 22, 2003 8:29 pm
Location: Michigan
Contact:

need help with some php code in my topsite

Post by metalhardscripts »

hey i keep getting a few errors in my topsite i just setup i fixed some little bugs but theres one big bug i know nothing about the error is error one on admin page is
Warning: Use of undefined constant url - assumed 'url' in D:\Webserver\www.everything.32k.org\topsite\admin.php on line 22
it still shows the url but i get this error and right next to this is this error
Warning: Use of undefined constant mail - assumed 'mail' in D:\Webserver\www.everything.32k.org\topsite\admin.php on line 23
and this is the same it still shows the email but i get that error and after these it should show a check box and under that a save button but dont show them and dont say a error for them any help would be great thanks
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

show us line 23 and 23
Jim
Forum Contributor
Posts: 238
Joined: Fri Apr 19, 2002 5:26 am
Location: Near Austin, Texas

Post by Jim »

An undefined constant is something like $variable that is.. well.. undefined.

Assumed : 'mail' means this:

$variable is read by PHP as '$variable'

To get rid of those errors, you can turn error_reporting off ;)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Your problem is probably with arrays:
http://www.php.net/manual/en/language.t ... rray.donts

Mac
User avatar
metalhardscripts
Forum Newbie
Posts: 8
Joined: Thu May 22, 2003 8:29 pm
Location: Michigan
Contact:

oh sorry heres the code

Post by metalhardscripts »

Code: Select all

<?php
global $adminpass,$action;
include("design.php");
session_start();
IF($adminpass == $conf['admin_pass']) {
session_register('adminpass');

IF(!$action) {
design_topp();
$sql1 = "SELECT * FROM sites WHERE accepted = 'no'";
$res1 = mysql_query($sql1);
$sql2 = "SELECT * FROM sites WHERE accepted = 'yes'";
$res2 = mysql_query($sql2);
?>
<p><?=$lang['members_to_be_accepted']?>:</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php
while ($out1 = mysql_fetch_array($res1)) 
{
?>
  <tr> 
    <td><font size="2"><a href="http://<?=$out1[url]?>" target="_blank"><?=$out1[url]?></a></font></td>
    <td><font size="2"><a href="mailto:<?=$out1[mail]?>"><?=$out1[mail]?></a></font></td>
    <td><font size="2"><a href="admin.php?action=accept&id=<?=$out1[ID]?>"><?=$lang['accept']?></a></font></td>
    <td><font size="2"><a href="admin.php?action=drop&id=<?=$out1[ID]?>"><?=$lang['drop']?></a></font></td>
  </tr>
	<?php } ?>
</table>
<p>&nbsp;</p>
<p><?=$lang['delete_or_admin_members']?>:</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <?php while($out2 = mysql_fetch_array($res2)) { ?>
	<tr> 
    <td><font size="2"><a href="http://<?=$out2[url]?>" target="_blank"><?=$out2[url]?></a></font></td>
    <td><font size="2"><a href="mailto:<?=$out2[mail]?>"><?=$out2[mail]?></a></font></td>
    <td><font size="2"><a href="admin.php?action=delete&id=<?=$out2[ID]?>"><?=$lang['delete']?></a></font></td>
    <td><font size="2"><a href="admin.php?action=edit&id=<?=$out2[ID]?>"><?=$lang['edit']?></a></font></td>
  </tr>
<?php } ?>
</table>
<p>&nbsp;</p>

<?php
design_bunn();
}
elseif($action == "accept") {
$sql = "SELECT * FROM sites WHERE ID = $id";
$res = mysql_query($sql);
$ut = mysql_fetch_array($res);
mysql_query("UPDATE sites SET accepted = 'yes' WHERE ID = $id");
header("Location: admin.php");
}
elseif($action == "drop") {
mysql_query("DELETE FROM sites WHERE ID = $id");
header("Location: admin.php");
}
elseif($action == "delete") {
mysql_query("DELETE FROM sites WHERE ID = $id");
header("Location: admin.php");
}
elseif($action == "edit") {
$sql = "SELECT * FROM sites WHERE ID = $id";
$res = mysql_query($sql);
$out = mysql_fetch_array($res);
?>
<form name="form1" method="post" action="admin.php?action=save">
  <input type="hidden" name="id" value="<?=$id?>">
	<table width="386" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td width="115"><font size="2"><?=$lang['name']?></font></td>
      <td width="385"> 
        <input type="text" name="name" value="<?=$out[name]?>">
      </td>
    </tr>
    <tr> 
      <td width="115"><font size="2"><?=$lang['url']?></font></td>
      <td width="385"> 
        <input type="text" name="url" value="http://<?=$out[url]?>">
      </td>
    </tr>
    <tr> 
      <td width="115"> <font size="2"><?=$lang['title']?></font></td>
      <td width="385"> 
        <input type="text" name="title" value="<?=$out[title]?>">
      </td>
    </tr>
    <tr> 
      <td width="115"><font size="2"><?=$lang['banner']?>(468x60)</font></td>
      <td width="385"> 
        <input type="text" name="banner" value="http://<?=$out[banner]?>">
      </td>
    </tr>
    <tr>
      <td width="115">&nbsp;</td>
      <td width="385"> 
        <input type="submit" name="Submit" value="<?=$lang['save']?>">
      </td>
    </tr>
  </table>
</form>
<?php
}
elseif($action == "save") {
$banner = eregi_replace("http://", "", $banner);
$url = eregi_replace("http://", "", $url);
mysql_query("UPDATE sites SET name = '$name', url = '$url', title = '$title', banner = '$banner' WHERE ID = $id");
header("Location: admin.php");
}
} // End of security
elseif($adminpass != $conf['admin_pass']) {
design_topp();
?><?=$lang['administration']?><br>
<form name="form1" method="post" action="admin.php">
  <input type="password" name="adminpass">
  <br>
  <input type="submit" name="Submit" value="<?=$lang['login']?>">
</form>
<?php
design_bunn();
}
?>
mod_edit:

Code: Select all

changed to

Code: Select all

[/size]
theres the code i still dont get what ya guys mean if you can help me more it would be great
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please visit the link Twigletmac gave you.
After you read the document compare

Code: Select all

<?=$out1[mail]?>
and

Code: Select all

<?=$lang['members_to_be_accepted']?>
(hint: note that the syntax highlighter marked mail and members_to_be_accepted with different colors)
User avatar
metalhardscripts
Forum Newbie
Posts: 8
Joined: Thu May 22, 2003 8:29 pm
Location: Michigan
Contact:

thank you all very much i fixed it

Post by metalhardscripts »

you all were great help i now see what i did wrong i had missed a few '' in the scripts now all pages work like they should come and check the up and working script at http://www.everything.32k.org/topsite/ again thank you all
Post Reply