Page 1 of 1
undefined index
Posted: Mon Jan 26, 2004 10:39 am
by ol4pr0
Been a little bit to hasty i guess.. it does work all hoever on load up it still does give this erros
Notice: Undefined index: Paqnr in line 33
after submitting ones the error goes away. its just onload up the first time.
so something is still wrong with this line
Code: Select all
// connectarse
mysql_select_db($dbase, $connect);
/* this line below still not correct
tried it with .$Paqnr.
SELECT * FROM pongo "; make the error go however it wont anything
on submit
*/
$query = "SELECT * FROM pongo WHERE Paqnr='" .$_GET['Paqnr']. "'";
$result = mysql_query($query);
if($row = mysql_fetch_array($result))
{
Posted: Mon Jan 26, 2004 10:45 am
by JayBird
its becuase the first time you load the page, it is trying to retrieve infor from the $_GET array, but you haven't submitted them form yet so it will not exist.
You need to put some logic into your code to only execute that part of the code after the form has been submitted.
Mark
Posted: Mon Jan 26, 2004 10:48 am
by ol4pr0
So how would i do that?
Could you give me a example?
Posted: Mon Jan 26, 2004 10:53 am
by JayBird
i presume you are still talking about the code i helped you with earlier.
Take a look at this
Code: Select all
<?
require ("include/styles.php");
// formulario, solo pone el codigo paquete
ECHO <<<HTML
<html>
<head>
<body class="v">
<form name="retrieve" action={$_SERVER['PHP_SELF']} method="GET" class="center">
<table width="250" border="0" class="center" cellpading="3">
<tr>
<td>
<div class="center"><b>Required information?</b></div>
</td>
</tr>
Enter Paq. number:<input type="text" name="Paqnr">
<br>
<Div class="r"><input name="submit" type="submit" ID="Paqnr" WIDTH="5"
CLASSID="CLSID:B6FC3A14-F837-11D0-9CC8-006008058734"></div>
HTML;
if (isset($_GET['Paqnr'])) { // Only execute this code if the Paqnr variable isset
// connectarse con el base datos.
$dbase ="home";
$tablename ="pongo";
$connect= mysql_connect('localhost')
or die("Cant connect: " .mysql_error());
// consultar el tabla pongo ( cambiar cuando listo )
$query = "SELECT * FROM pongo WHERE Paqnr='" .$_GET['Paqnr']. "'";
$result = mysql_query($query);
if($row = mysql_fetch_array($result)) {
echo "<tr class="V"> ";
echo "<td width="100" class="v"> ";
echo "<div class="r">Numero Paquete</div> ";
echo "</td>\n ";
echo "<td width="150"> ";
echo $row['Paqnr'];
echo " </td>\n ";
AND SO ON
}
}
?>
Mark
Posted: Mon Jan 26, 2004 10:55 am
by ol4pr0
Thanks let me try that one..
i was already messing with
Guess that wouldnt of worked
Worked nicely, thanks alot for all the help
these kind of lines are now graved into my brain

Posted: Mon Jan 26, 2004 11:01 am
by JayBird
you method would work if you had register_globals turned on in your php.ini.
but the way i suggested is a better method to get used to.
Mark