[thelist] help with project design

Abdullah Mancy mancy3000 at gmail.com
Tue Nov 25 15:27:54 CST 2008


Hi Terion,
please try this

<?
$items = array('HREF'=>'link',' TITLE'=>'title','
BLURB'=>'text','BDATE'=>'beginning date','EDATE'=>'end date','EXPOS'=>'');
foreach($items as $item => $message)
{
  if(isset($_POST[$item]))
  {
    $$item = $_POST[$item];
  }
  else
  {
    $$item = "";
    $errormsg = "Please Select " . $message . " for the AD.";
  }
}
mysql_select_db($mysql);

$sql = "INSERT INTO textads (HREF, TITLE, BLURB,BDATE,EDATE,EXPOS) VALUES
('$HREF','$BLURB', '$BDATE', '$EDATE', '$EXPOS')";
mysql_query($sql) or die('Error, insert query failed');

?>


your err. is here btw: ('$HREF','$BLURB', '$BDATE', '$EDATE', '$EXPOS')";
when you wrote ('HREF','BLURB', 'BDATE', 'EDATE', 'EXPOS')";

haven't tested the code i re-factored, but please let me know if it works
well or Not.

Mancy

On Tue, Nov 25, 2008 at 11:18 PM, Terion Miller <webdev.terion at gmail.com>wrote:

> On Tue, Nov 25, 2008 at 3:13 PM, Matt McKeon <matt at camadro.com> wrote:
>
> > Terion Miller wrote:
> > > I have to make a form to add text ads to a db then have those ads
> display
> > in
> > > a table with 3 columns 1 ad per column and this little application has
> to
> > > work inside the Helios adserver, I'm stuck because at this point I
> can't
> > > even get my form working on my local server...
> > >
> > > all the code I have written thus far:
> > >
> > > <?php include("inc/dbConnOpen.php") ;   /* connect */
> > >
> > > if (isset($_POST['HREF'])){$HREF = $_POST['HREF'];} else {$HREF = "";}
> > >     {$errmsg = 'Please Select a LINK FOR THE AD';}
> > > if (isset($_POST['TITLE'])){$TITLE = $_POST['TITLE'];} else {$TITLE =
> > "";}
> > > {$errmsg = 'Please Select a TITLE FOR THE AD';}
> > > if (isset($_POST['BLURB'])){$BLURB = $_POST['BLURB'];} else {$BLURB =
> > "";}
> > > {$errmsg = 'Please enter the text for the ad';}
> > > if (isset($_POST['BDATE'])){$BDATE = $_POST['BDATE'];} else {$BDATE =
> > "";}
> > > {$errmsg = 'Please enter the beginning date for the ad';}
> > > if (isset($_POST['EDATE'])){$EDATE = $_POST['EDATE'];} else {$EDATE =
> > "";}
> > > {$errmsg = 'Please enter the end date for the ad';}
> > >
> > > mysql_select_db($mysql);
> > > $sql = "INSERT INTO textads (HREF, TITLE, BLURB,BDATE,EDATE,EXPOS)
> VALUES
> > > ('HREF',' BLURB', 'BDATE', 'EDATE', 'EXPOS')";
> > > mysql_query($sql) or die('Error, insert query failed');
> > > ?>
> > >
> > So, are you getting errors or what's happening when you run this?
> >
> > Hum, looks like you've got a lot of syntax errors.
> > What do these lines mean  {$errmsg = 'Please enter the text for the ad';}
> ?
> >
> > I'm assuming they should be a part of the else? It should then look more
> > like:
> > if (isset($_POST['BLURB'])) {
> >   $BLURB = $_POST['BLURB'];
> > } else {
> >   $BLURB = "";
> >   $errmsg = 'Please enter the text for the ad';
> > }
> >
> > That should be a start since you didn't specify what you need help with.
> >
> > HTH
> > Matt
> >
> > --
> >
> > * * Please support the community that supports you.  * *
> > http://evolt.org/help_support_evolt/
> >
> > For unsubscribe and other options, including the Tip Harvester
> > and archives of thelist go to: http://lists.evolt.org
> > Workers of the Web, evolt !
> >
> Thanks that did help, for some reason I'm having so many problems with php
> (
> I have mostly been only layout and design as in html and css person)
> so now I have (thought I would get to the basics) ;
> <?php
> if(isset($_POST['add']))
> {
> include 'inc/dbconnOpen.php';
> $HREF = $_POST['HREF'];
> $TITLE = $_POST['TITLE'];
> $BLURB = $_POST['BLURB'];
>
> $query = "INSERT INTO 'textads' ('HREF', 'BLURB', 'TITLE') VALUES ('$HREF',
> '$TITLE', '$BLURB'), 'Y', 'Y', 'Y')";
> mysql_query($query) or die('Error, friggin insert query failed');
>
> echo "New Dream Job Text Ad  added";
> }
> else
> {
> ?>
> <form method="post">
> <table width="400" border="0" cellspacing="1" cellpadding="2">
> <tr>
> <td width="100">TITLE</td>
> <td><input name="TITLE" type="text" id="TITLE"></td>
> </tr>
> <tr>
> <td width="100">Blurb</td>
> <td><input name="BLURB" type="text" id="BLURB"></td>
> </tr>
> <tr>
> <td width="100">LINK</td>
> <td><input name="HREF" type="text" id="HREF"></td>
> </tr>
>
>
> <tr>
> <td width="100">&nbsp;</td>
> <td><input name="add" type="submit" id="add" value="Add AD"></td>
> </tr>
> </table>
> </form>
> <?php
> }
> ?>
> </body>
> </html>
>
>
> and still can't get it to insert ....I am trying to follow tutorials but I
> just don't get it...
> --
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>



More information about the thelist mailing list