RE: PHP/MySQL and passing url params

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Why'd you use it in the first place?  Where does $row_rsID['userID'] get
set?  Why is it in your script if you don't know where it is set and what
it is set to?

You set it like this:

$row_rsID['userID'] = "whatever you want here, probably an int like '0'";

Several ways to define arrays:

$array = array(); // set empty array

$hash = array("stuff"=>"foo");  // a hash effectively

$array = array();
array_push($array, "stuff to push onto the array");

$array[] = "foo"; // same as "array_push"

$array[37] = "foo"; // set array index 37 to foo.

$array['stuff'] = "foo"; // set "hash" (array using words) stuff to foo

$array[0][0][stuff] = "foo"; //multidimensional array.

$array[0][1][stuff] = array("stuff"=>"foo");

Peter

On Mon, 28 Oct 2002, alex hogan wrote:

> How do I set $row_rsID['userID']?
>
> Do I use (isset($row_rsID['userID']); or something similar?
>
> Would I define an array, $my_array[]; and then look to populate the
> array dynamically?
> $my_array[0] = "something";
> $my_array[1] = "something else";
>
> I've probably missed something in the docs but I don't seem to find any
> hard fast rules on defining arrays or rediminsioning them.
>
> alex
>
> > -----Original Message-----
> > From: Peter Beckman [mailto:beckman@purplecow.com]
> > Sent: Sunday, October 27, 2002 9:29 PM
> > To: alex hogan
> > Cc: php-db@lists.php.net
> > Subject: RE:  PHP/MySQL and passing url params
> >
> > The first question is is $row_rsID actually an array when you run the
> > script?
> >
> > If it is, is $row_rsID['userID'] set?
> >
> > If it isn't, is $row_rsID['userid'] set?
> >
> > If you want to set the variable $row_rsID statically do this:
> >
> > $row_rsID = array("userID"=>1);
> >
> > Where does $row_rsID get set?  Does it set $row_rsID['userID']?
> >
> > Peter
> >
> > On Sun, 27 Oct 2002, alex hogan wrote:
> >
> > > Sorry..., my bad.  Too wrapped up in the problem.
> > >
> > >
> > >
> > > Notice: Undefined variable: row_rsID in
> > > D:\web\hogana\demo\login\TMPbl2tw4o24u.php on line 48
> > >
> > > Warning: Cannot add header information - headers already sent by
> (output
> > > started at D:\web\hogana\demo\login\TMPbl2tw4o24u.php:48) in
> > > D:\web\hogana\demo\login\TMPbl2tw4o24u.php on line 53
> > >
> > > <?php require_once('../../Connections/connReg.php'); ?>
> > > <?php
> > > function GetSQLValueString($theValue, $theType, $theDefinedValue =
> "",
> > > $theNotDefinedValue = "")
> > > {
> > >   $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) :
> > > $theValue;
> > >
> > >   switch ($theType) {
> > >     case "text":
> > >       $theValue = ($theValue != "") ? "'" . $theValue . "'" :
> "NULL";
> > >       break;
> > >     case "long":
> > >     case "int":
> > >       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
> > >       break;
> > >     case "double":
> > >       $theValue = ($theValue != "") ? "'" . doubleval($theValue) .
> "'" :
> > > "NULL";
> > >       break;
> > >     case "date":
> > >       $theValue = ($theValue != "") ? "'" . $theValue . "'" :
> "NULL";
> > >       break;
> > >     case "defined":
> > >       $theValue = ($theValue != "") ? $theDefinedValue :
> > > $theNotDefinedValue;
> > >       break;
> > >   }
> > >   return $theValue;
> > > }
> > >
> > > $editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
> > > if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
> > >   $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
> > > }
> > >
> > > if ((isset($HTTP_POST_VARS["MM_insert"])) &&
> > > ($HTTP_POST_VARS["MM_insert"] == "frmReg")) {
> > >   $insertSQL = sprintf("INSERT INTO user (username, fname, lname,
> > > address, city, `state`, zip, phone, email) VALUES (%s, %s, %s, %s,
> %s,
> > > %s, %s, %s, %s)",
> > >
> GetSQLValueString($HTTP_POST_VARS['txtUserName'],
> > > "text"),
> > >
> GetSQLValueString($HTTP_POST_VARS['txtFName'],
> > > "text"),
> > >
> GetSQLValueString($HTTP_POST_VARS['txtLName'],
> > > "text"),
> > >
> GetSQLValueString($HTTP_POST_VARS['txtAddress'],
> > > "text"),
> > >                        GetSQLValueString($HTTP_POST_VARS['txtCity'],
> > > "text"),
> > >
> GetSQLValueString($HTTP_POST_VARS['txtState'],
> > > "text"),
> > >                        GetSQLValueString($HTTP_POST_VARS['txtZip'],
> > > "text"),
> > >
> GetSQLValueString($HTTP_POST_VARS['txtPhone'],
> > > "text"),
> > >
> GetSQLValueString($HTTP_POST_VARS['txtEmail'],
> > > "text"));
> > >
> > >   mysql_select_db($database_connHoganMain, $connHoganMain);
> > >   $Result1 = mysql_query($insertSQL, $connHoganMain) or
> > > die(mysql_error());
> > >
> > > //Line 48 below -
> > >
> > >   $insertGoTo = "thanks.php?id=" . $row_rsID['userID'] . "";
> > >   if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
> > >     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
> > >     $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
> > >   }
> > >
> > > //Line 53 below -
> > >   header(sprintf("Location: %s", $insertGoTo));
> > > }
> > >
> > > mysql_select_db($database_connHoganMain, $connHoganMain);
> > > $query_rsID = "SELECT * FROM `user`";
> > > $rsID = mysql_query($query_rsID, $connHoganMain) or
> die(mysql_error());
> > > $row_rsID = mysql_fetch_assoc($rsID);
> > > $totalRows_rsID = mysql_num_rows($rsID);
> > > ?>
> > > <html>
> > > <head>
> > > <title>User Registration</title>
> > > <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> > > </head>
> > >
> > > <body>
> > > <h1><strong><font size="6" face="Arial, Helvetica, sans-serif">Enter
> > > Registration
> > >   Information </font></strong></h1>
> > > <form action="<?php echo $editFormAction; ?>" method="POST"
> > > name="frmReg" id="frmReg">
> > >   <p><font size="2" face="Arial, Helvetica, sans-serif">You must
> fill in
> > > all the
> > >     required fields.</font></p>
> > >   <table width="51%" border="1">
> > >     <tr>
> > >       <td width="29%" bgcolor="#CCCCCC"> <div
> > > align="right"><strong><font size="2" face="Arial, Helvetica,
> > > sans-serif">First
> > >           Name: </font></strong></div></td>
> > >       <td width="71%"><div align="left">
> > >           <input name="txtFName" type="text" id="txtFName" size="30"
> > > maxlength="28">
> > >         </div></td>
> > >     </tr>
> > >     <tr>
> > >       <td bgcolor="#CCCCCC"> <div align="right"><strong><font
> size="2"
> > > face="Arial, Helvetica, sans-serif">Last
> > >           Name: </font></strong></div></td>
> > >       <td><div align="left">
> > >           <input name="txtLName" type="text" id="txtLName" size="30"
> > > maxlength="28">
> > >         </div></td>
> > >     </tr>
> > >     <tr>
> > >       <td bgcolor="#CCCCCC"> <div align="right"><strong><font
> size="2"
> > > face="Arial, Helvetica, sans-serif">Address:
> > >           </font></strong></div></td>
> > >       <td><div align="left">
> > >           <input name="txtAddress" type="text" id="txtAddress"
> size="40"
> > > maxlength="38">
> > >         </div></td>
> > >     </tr>
> > >     <tr>
> > >       <td bgcolor="#CCCCCC"> <div align="right"><strong><font
> size="2"
> > > face="Arial, Helvetica, sans-serif">City:
> > >           </font></strong></div></td>
> > >       <td><div align="left">
> > >           <input name="txtCity" type="text" id="txtCity" size="25"
> > > maxlength="23">
> > >         </div></td>
> > >     </tr>
> > >     <tr>
> > >       <td bgcolor="#CCCCCC"> <div align="right"><strong><font
> size="2"
> > > face="Arial, Helvetica, sans-serif">State:
> > >           </font></strong></div></td>
> > >       <td><div align="left">
> > >           <input name="txtState" type="text" id="txtState" size="28"
> > > maxlength="26">
> > >         </div></td>
> > >     </tr>
> > >     <tr>
> > >       <td bgcolor="#CCCCCC"> <div align="right"><strong><font
> size="2"
> > > face="Arial, Helvetica, sans-serif">Zip:
> > >           </font></strong></div></td>
> > >       <td><div align="left">
> > >           <input name="txtZip" type="text" id="txtZip" size="12"
> > > maxlength="10">
> > >         </div></td>
> > >     </tr>
> > >     <tr>
> > >       <td bgcolor="#CCCCCC"> <div align="right"><strong><font
> size="2"
> > > face="Arial, Helvetica, sans-serif">Phone:
> > >           </font></strong></div></td>
> > >       <td><div align="left">
> > >           <input name="txtPhone" type="text" id="txtPhone" size="14"
> > > maxlength="12">
> > >         </div></td>
> > >     </tr>
> > >     <tr>
> > >       <td bgcolor="#CCCCCC"><div align="right"><strong><font
> size="2"
> > > face="Arial, Helvetica,
> sans-serif">UserName:</font></strong></div></td>
> > >       <td><input name="txtUserName" type="text" id="txtUserName"
> > > size="27" maxlength="25"></td>
> > >     </tr>
> > >     <tr>
> > >       <td bgcolor="#CCCCCC"> <div align="right"><strong><font
> size="2"
> > > face="Arial, Helvetica, sans-serif">eMail
> > >           Address: </font></strong></div></td>
> > >       <td><div align="left">
> > >           <input name="txtEmail" type="text" id="txtEmail" size="40"
> > > maxlength="38">
> > >         </div></td>
> > >     </tr>
> > >   </table>
> > >   <br>
> > >   <input name="Submit" type="submit" id="Submit" value="Submit">
> > >   <input name="Reset" type="reset" id="Reset" value="Reset">
> > >   <input type="hidden" name="MM_insert" value="frmReg">
> > > </form>
> > > <p><br>
> > > </p>
> > > <p><strong><font size="3" face="Arial, Helvetica,
> > > sans-serif"></font></strong>
> > > </p>
> > >
> > > <?php
> > > mysql_free_result($rsID);
> > > ?>
> > >
> > >
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >
> ------------------------------------------------------------------------
> ---
> > Peter Beckman            Systems Engineer, Fairfax Cable Access
> Corporation
> > beckman@purplecow.com
> http://www.purplecow.com/
> >
> ------------------------------------------------------------------------
> ---
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

---------------------------------------------------------------------------
Peter Beckman            Systems Engineer, Fairfax Cable Access Corporation
beckman@purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux