You are here: Re: variable problem in address book script « All PHP « IT news, forums, messages
Re: variable problem in address book script

Posted by Mr. Newt on 01/02/07 02:33

"Geoff Berrow" <blthecat@ckdog.co.uk> wrote in message
news:usbjp2153rshs4e0l9pgjg08o90lj7f0t5@4ax.com...
> Message-ID: <QtSdnZcWLrYmxQTYnZ2dnUVZ_oKnnZ2d@adelphia.com> from Mr.
> Newt contained the following:
>
>>Thanks for the help guys. I'm sorry for wasting your time, but I'm going
>>to
>>find another script that hopefully works out of the box instead of trying
>>to
>>fix old stuff. It's definitely been a learning experience, so it hasn't
>>all
>>been a waste of time (on my part).
>
> Why not write your own?

I really don't know anything about PHP except what I picked up over the past
2 weekends during free time. I'm beginning to think I should get a PHP for
dummies book.

I found another address book script that pretty much worked out of the box.
A couple error messages that were fixed with your suggestions for the
previous address book (I guess there are a lot of outdated scripts out
there). There's only one error message that I have no idea what to do about
(I even googled it before coming back to you guys).

PHP Notice: Uninitialized string offset: 0 in
E:\Inetpub\wwwroot\experiment\addressbook\edit.php on line 163
(code posted below)

Any ideas?

Thanks. Robert

**************************
<?
include ("include/header.inc.php");
?>

<h1>Edit / add address book entry</h1>
<?php
include("include/dbconnect.php");

$submit=(isset($_GET['submit']))?($_GET['submit']) : "" ;
$update=(isset($_GET['update']))?($_GET['update']) : "" ;
$id=(isset($_GET['id']))?($_GET['id']) : "" ;
$myrow=(isset($_GET['myrow']))?($_GET['myrow']) : "" ;

//notice your fix above?


if($submit)
{

$sql = "INSERT INTO $table (firstname, lastname, address, home, mobile,
work, email, email2, bday, bmonth, byear) VALUES
('$firstname','$lastname','$address','$home','$mobile','$work','$email','$email2','$bday','$bmonth','$byear')";
$result = mysql_query($sql);
echo "<br><br>Information entered into address book.\n";
}
else if($update)
{
$sql = "UPDATE $table SET
firstname='$firstname',lastname='$lastname',address='$address',home='$home',mobile='$mobile',work='$work',email='$email',email2='$email2',bday='$bday',bmonth='$bmonth',byear='$byear'
WHERE id=$id";
$result = mysql_query($sql);
echo "<br><br>Address book updated.\n";
}
else if($id)
{
$result = mysql_query("SELECT * FROM $table WHERE id=$id",$db);
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="edit.php">

<table width="380" border="0" cellspacing="1" cellpadding="1">
<tr>
<td>
<input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
Firstname: </td>
<td>
<input type="Text" name="firstname" size="35" value="<?php echo
$myrow["firstname"]?>">
</td>
</tr>
<tr>
<td>Lastname:</td>
<td>
<input type="Text" name="lastname" size="35" value="<?php echo
$myrow["lastname"]?>">
</td>
</tr>
<tr>
<td>Address: </td>
<td>
<textarea name="address" rows="5" cols="35"><?php echo
$myrow["address"]?></textarea>
</td>
</tr>
<tr>
<td>Telephone:</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Home:</td>
<td>
<input type="Text" name="home" value="<?php echo $myrow["home"]?>">
</td>
</tr>
<tr>
<td>Mobile:</td>
<td>
<input type="Text" name="mobile" value="<?php echo
$myrow["mobile"]?>">
</td>
</tr>
<tr>
<td>Work: </td>
<td>
<input type="Text" name="work" value="<?php echo $myrow["work"]?>">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Email:</td>
<td>
<input type="Text" name="email" size="35" value="<?php echo
$myrow["email"]?>">
</td>
</tr>
<tr>
<td>Email2:</td>
<td>
<input type="Text" name="email2" size="35" value="<?php echo
$myrow["email2"]?>">
</td>
</tr>
<tr>
<td>Birthday:</td>
<td>
<select name="bday">
<option value="<?php echo $myrow["bday"]?>" selected><?php echo
$myrow["bday"]?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="bmonth">
<option value="<?php echo $myrow["bmonth"]?>" selected><?php echo
$myrow["bmonth"]?></option>
<option value="January" selected>January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
<input type="text" name="byear" size="4" maxlength="4" value="<?php
echo $myrow["byear"]?>">
</td>
</tr>
</table>
<input type="Submit" name="update" value="Update information">
</form>
<?

}
else
{
?>
<form method="post" action="<?php echo $PHP_SELF?>">

<table width="380" border="0" cellspacing="1" cellpadding="1">
<tr>
<td>
<input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
Firstname:</td>
<td>
<input type="Text" name="firstname" size="35">
</td>
</tr>
<tr>
<td>Lastname: </td>
<td>
<input type="Text" name="lastname" size="35">
</td>
</tr>
<tr>
<td>Address: </td>
<td>
<textarea name="address" rows="5" cols="35"></textarea>
</td>
</tr>
<tr>
<td>Telephone:</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Home:</td>
<td>
<input type="Text" name="home">
</td>
</tr>
<tr>
<td>Mobile: </td>
<td>
<input type="Text" name="mobile">
</td>
</tr>
<tr>
<td>Work:</td>
<td>
<input type="Text" name="work">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Email: </td>
<td>
<input type="Text" name="email" size="35">
</td>
</tr>
<tr>
<td>Email2: </td>
<td>
<input type="Text" name="email2" size="35">
</td>
</tr>
<tr>
<td>Birthday:</td>
<td>
<select name="bday">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="bmonth">
<option value="January" selected>January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
<input type="text" name="byear" size="4" maxlength="4">
</td>
</tr>
</table>
<input type="Submit" name="submit" value="Enter information">
</form>
<?
}

include ("include/footer.inc.php");
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация