Forum Moderators: coopster
I am getting an error message, saying that the variables from the acctmgr table are undefined. I am not sure what I am missing. Any help would be great!
This is the error message:
SELECT * from diw
Notice: Undefined variable: acctmgr_phone in c:\program files\easyphp1-7\www\diw4.php on line 40
Notice: Undefined variable: acctmgr_cellphone in c:\program files\easyphp1-7\www\diw4.php on line 40
Notice: Undefined variable: acctmgr_email in c:\program files\easyphp1-7\www\diw4.php on line 40
This is my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
$connect= mysql_connect("localhost","root","****")
or die("Could not connect to database in localhost!");
$result=mysql_select_db("testdiw")
or die("Could not select that database!");
echo "SELECT * from testdiw";
$joined = date("Y-m-d h:i:s");
$sqlquery = "INSERT INTO diw VALUES('','". $diwtitle ."','". $dropdownacctmgr ."','". $joined ."')";
$sqlquery = "SELECT * from diw";
$queryresult = mysql_query($sqlquery) or die(" Could not execute mysql query!");
$get_acctmgr_info = mysql_query("SELECT acctmgr_phone, acctmgr_cellphone, acctmgr_email FROM acctmgr WHERE acctmgr_name = '$dropdownacctmgr'");
$row=mysql_fetch_array($get_acctmgr_info);
echo '<table border=1 align=center width=500>
<TR>
<TD colspan=2><b>General Deposition
Information></b></TD>
</TR>
<TR>
<TD><b>DIW Title:</b></TD>
<TD>' .$diwtitle. '</TD>
</TR>
<TR>';
echo ' <TD>Account Manager Information:</TD> <TD>' .$dropdownacctmgr. '<BR>' .$acctmgr_phone. '<BR>' .$acctmgr_cellphone. '<BR>' .$acctmgr_email. '</TD>
</TR>
</TABLE>';
?>
</body>
</html>
I follow that.. But, the undefined variables which I get the error for are associated with a variable that is defined..
$get_acctmgr_info = mysql_query("SELECT acctmgr_phone, acctmgr_cellphone, acctmgr_email FROM acctmgr WHERE acctmgr_name = '$dropdownacctmgr'");
$row=mysql_fetch_array($get_acctmgr_info);
The variable $dropdownacctmgr is defined on the page which leads to this. The variable $dropdownacctmgr displays even. So I am wondering if there is an error with the query which looks for a commonality between $dropdownacctmgr and acctmgr_name?
I checked to see if the variable $dropdownacctmgr was set my inserting the code
if (isset($dropdownacctmgr)) {
echo "This var is set set so I will print.";
}
into the script and it echoed back as being set. Does this point to a problem with the query syntax?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
$connect= mysql_connect("localhost","root","cpyter")
or die("Could not connect to database in localhost!");
$result=mysql_select_db("testdiw")
or die("Could not select that database!");
?>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<form action="diw5.php" method="post">
<TABLE>
<tr>
<td align="center" HEIGHT="65" width="100" colspan="2" BGCOLOR="#cc0000"><b>General Deposition Information</b></td>
</tr>
<tr><!-- ROW 2, TABLE 2 -->
<td width="40%"><small><b><font face="Arial">DIW Title:</font></b></small></td>
<td><input type="text" name="diwtitle" size="32"></td>
</tr>
<tr>
<td valign="top"><small><b><font face="Arial">Account Manager</font></b></small></td>
<td><select name="dropdownacctmgr" tabindex="4"><option value="notset">- Select an account manager -</option>
<?
//--- CREATE Account Manager SELECT ---
$sql = "SELECT DISTINCT acctmgr_name FROM acctmgr ORDER BY acctmgr_name";
$acctmgr_name = mysql_query($sql) or die($sql . '<br />' . mysql_error());
while ($row = mysql_fetch_array($acctmgr_name)) {
echo '<option value="' . $row['acctmgr_name'] . '">' . $row['acctmgr_name'] . '</option>';
}
?>
</td>
</tr>
<TR>
<TD COLSPAN=2><input type="submit" name="Submit" value="Submit" action="required"></TD></FORM>
</TR>
</TABLE>
</body>
</html>
And tjhis is the code for the page with the problems as I currently have it:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
$connect= mysql_connect("localhost","root","cpyter")
or die("Could not connect to database in localhost!");
$result=mysql_select_db("testdiw")
or die("Could not select that database!");
echo "SELECT * from diw";
$joined = date("Y-m-d h:i:s");
$sqlquery = "INSERT INTO diw VALUES('','". $diwtitle ."','". $dropdownacctmgr ."','". $joined ."')";
$sqlquery = "SELECT * from diw";
$queryresult = mysql_query($sqlquery) or die(" Could not execute mysql query!");
echo "<table border=1 align=center width=500>";
echo "<TR>";
echo "<TD colspan=2><b>General Deposition";
echo "Information></b></TD>";
echo "</TR>";
echo "<TR>";
echo "<TD><b>DIW Title:</b></TD>";
echo "<TD>" .$diwtitle. "</TD>";
echo "</TR>";
echo "<TR>";
echo "<TD>Account Manager Information:</TD> <TD>" .$dropdownacctmgr. "<BR>";
//$get_acctmgr_info = mysql_query("SELECT acctmgr_phone, acctmgr_cellphone, acctmgr_email FROM acctmgr WHERE acctmgr_name = '$dropdownacctmgr'");
$get_acctmgr_info = mysql_query("SELECT acctmgr_phone, acctmgr_cellphone, acctmgr_email FROM acctmgr WHERE acctmgr_name = '".$_POST['dropdownacctmgr']."'");
$row=mysql_fetch_array($get_acctmgr_info);
if (isset($acctmgr_name)) {
echo "This var is set set so I will print.";
}
echo "" .$acctmgr_phone. "<BR>" .$acctmgr_cellphone. "<BR>" .$acctmgr_email. "</TD>";
echo "</TR>";
echo "</TABLE>";
?>
</body>
</html>
if (isset($_POST['Submit']))
{
$diwtitle = $_POST['title'];
$dropdownacctmgr = $_POST['dropdownacctmgr'];
}
also change:
SELECT acctmgr_phone, acctmgr_cellphone, acctmgr_email FROM acctmgr...
to simply:
SELECT * FROM acctmgr..
See if that helps.
dc
Notice: Undefined variable: acctmgr_cellphone in c:\program files\easyphp1-7\www\diw5.php on line 52
Notice: Undefined variable: acctmgr_email in c:\program files\easyphp1-7\www\diw5.php on line 52"
...
$get_acctmgr_info = mysql_query("SELECT acctmgr_phone, acctmgr_cellphone, acctmgr_email FROM acctmgr WHERE acctmgr_name = '".$_POST['dropdownacctmgr']."'");
$row=mysql_fetch_array($get_acctmgr_info);
$acctmgr_phone = $row['acctmgr_phone'];
$acctmgr_cellphone = $row['acctmgr_cellphone'];
$acctmgr_email = $row['acctmgr_email'];
if (isset($acctmgr_name)) {
echo "This var is set set so I will print.";
}
echo "" .$acctmgr_phone. "<BR>" .$acctmgr_cellphone. "<BR>" .$acctmgr_email. "</TD>";
...