Can't figure out my problem...

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
PaulD233
Forum Newbie
Posts: 5
Joined: Tue Aug 22, 2006 12:33 pm

Can't figure out my problem...

Post by PaulD233 »

Please look at the code below. It supposed to allow you to sign up for an item, and then your name will repost after you've signed up. It allows you to sign up, but it doesn't repost your name. Thank you for your help.
Here is the site

Code: Select all

<?php
$dbh=mysql_connect ("localhost", "dvdcreat_dev", "dev") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("dvdcreat_unionsbcdevelopment"); 
#echo "you did it!!";
$types = array ("No Camera","With Camera");
$count = 8;
if ($_POST)
{
    #print_r ($_POST);
	$signeduptypes=array();
	foreach($_POST as $name => $value)
	{
		if ($value)
		{	
			$newname=explode("_",$name);
			$newname=$newname [0];
			$signeduptypes[]=$newname;
			#echo "You signed up for $newname";
			$sql="insert into signupnov(type,name) values('$newname','$value')";
			mysql_query($sql);
		}
	}
	if ($signeduptypes)$message="You signed up for ".implode(", ",$signeduptypes);
	header("Location: ".$_SERVER["SCRIPT_NAME"]."?message=".urlencode($message));
}
$sql="select type, name from signupnov";
$result=mysql_query($sql);
#print_r($result);
while($savedresultsnov=mysql_fetch_array($result))
{
	$signupsheetnov[$savedresultsnov[0]][]=$savedresultsnov[1];
}
$message=$_GET["message"];
#print_r($savedresultsnov);
#print_r ($signupsheetnov);
?>

Code: Select all

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>the Union - Sign Up Sheet November</title>
</head>

<body bgcolor="#FFFFCD">

<form method="POST" action="<?=$PHP_SELF?>" name="Signupnov">
	
	<h2><font face="Comic Sans MS"><?=$message?></font></h2>
	<p><font face="Comic Sans MS" color="#FF9900">Please sign up for at least one of the following:</font></p>
	<table border="0" style="border-collapse: collapse" cellpadding="10" width="509" id="table1">
		<?php
		foreach ($types as $number => $type)
		{
			if ($number % 2 == 0)
			{
			?>
		<tr>
		<?php
			}
		?>
		
			<td  style="vertical-align:top; text-align:right" width="100"><font face="Comic Sans MS" color="#FF9900"><?=$type?>:</font></td>
			<td>
		
		<?php
		for ($i=0;$i<$count;++$i)
		{
			if ($signupsheetnov[$type][$i])
			{
		?>
		<font face="Comic Sans MS"><?=$signupsheetnov[$type][$i]?></font><br>
		<?php
				
			}
			else
			{
				$inputavailable=true;
				
		?>
		
			
	<font color="#FF9900">
	<input type="text" name="<?=$type."_".$i?>"size="auto"></font><br>
		<?php
			}
		}
		?>
		</td>
		<?php
			if ($number %2 != 0)
			{
		?>
		</tr>
		<?php
		}
		}
		?>
	</table>
	
  <p><font face="Comic Sans MS" color="#FF9900">Thank you.</font></p>
  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	&nbsp; 
	<?php
	if($inputavailable)
	{
	?>
	<input type="submit" value="Submit"><input type="reset" value="Reset" name="B2">
	<?php
	}
	?></p>
</form>

</body>

</html>
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Perhaps you could elaborate on the problem. Tell us which part is working, and which part of the code isn't doing what you're expecting. Let us know of any errors as well.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Worst case solution, echo your assignments to see what is exactly being setup in your script.
PaulD233
Forum Newbie
Posts: 5
Joined: Tue Aug 22, 2006 12:33 pm

Post by PaulD233 »

No errors show up, it's just that after signing up for an item and returning back to the sign up page, the name of the person who signed up is supposed to show up. However, no name shows up.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Which part of that code is the name? And where is it assigned? Try echoing out the value for name at the time the assignment is done. Also, consider turning error_reporting up toi E_ALL and setting display_errors to On, just for testing.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
Run the following in a new file and tell us the results please.

Code: Select all

<?php

$neg = array('off', 0, false, '', null);
$flags = array(
	'Register Globals' => 'register_globals',
	'Short Tags' => 'short_open_tag',
	'Display Errors' => 'display_errors',
	'Magic Quotes GPC' => 'magic_quotes_gpc',
	'Magic Quotes Runtime' => 'magic_quotes_runtime',
	'Magic Quotes Sybase' => 'magic_quotes_sybase',
);
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
foreach ($flags as $n => $v)
{
	$flags[$n] = (in_array(strtolower(ini_get($v)), $neg) ? 'Off' : 'On');
}
$cli = (php_sapi_name() == 'cli');
$eol = "\n";

$gle = get_loaded_extensions();
$rows = array();
$le = '';
$wide = 4;
$j = count($gle);
$pad = $wide - $j % $wide;
$len = max(array_map('strlen', $gle));
$func = create_function('$a', 'return str_pad($a, ' . intval($len) . ');');
$gle = array_map($func, $gle);
for($i = 0; $i < $j; $i += $wide)
{
	$le .= '   ' . implode('   ', array_slice($gle, $i, $wide)) . $eol;
}

$ec = array(
	'E_STRICT' => 2048, 'E_ALL' => 2047, 'E_USER_NOTICE' => 1024,
	'E_USER_WARNING' => 512, 'E_USER_ERROR' => 256, 'E_COMPILE_WARNING' => 128,
	'E_COMPILE_ERROR' => 64, 'E_CORE_WARNING' => 32, 'E_CORE_ERROR' => 16,
	'E_NOTICE' => 8, 'E_PARSE' => 4, 'E_WARNING' => 2, 'E_ERROR' => 1,
);

$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
	if (($t & $v) == $v)
	{
		$e[] = $n;
		$t ^= $v;
	}
}
if (ceil(count($ec) / 2) + 1 < count($e))
{
	$e2 = array();
	foreach ($ec as $n => $v)
	{
		if (!in_array($n, $e) and $n != 'E_ALL')
		{
			$e2[] = $n;
		}
	}
	$er = $er . ' ((E_ALL | E_STRICT) ^ ' . implode(' ^ ', $e2) . '))';
}
else
{
	$er = $er . ' (' . implode(' | ', $e) . ')';
}

if (!$cli)
{
	echo '<html><head><title>quick info</title></head><body><pre>', $eol;
}

echo 'PHP Version: ', $ve, $eol;
echo 'PHP OS: ', $os, $eol;
echo 'Error Reporting: ', $er, $eol;
foreach ($flags as $n => $v)
{
	echo $n, ': ', $v, $eol;
}
echo 'Loaded Extensions:', $eol, $le, $eol;

if (!$cli)
{
	echo '</pre></body></html>', $eol;
}

?>
Post Reply