Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Mon Jan 26, 2004 10:39 am
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))
{
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Mon Jan 26, 2004 10:45 am
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
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Mon Jan 26, 2004 10:48 am
So how would i do that?
Could you give me a example?
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Mon Jan 26, 2004 10:53 am
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
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Mon Jan 26, 2004 10:55 am
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
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Mon Jan 26, 2004 11:01 am
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