Jump to content

greggustin

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Posts posted by greggustin

  1. guess I am having trouble with the "LOCATION" command?

    ie

    after I have the user hit submit - it dumps to the 'mail.php page

    (which is very simple - ie not a full html page)

    do I have to make the mail.php into a full stylized html?

    hope not

    thought I could do a redirect back to the origination page in the website

    I commented out the location command as it was not working

    idea?

    <?php

    $Name=$_POST['Name'];

    $email=$_POST['email'];

    $comments=$_POST['comments'];

    $to="greg@BlahBlah.com";

    $message="

    From: $Name\n

    E-Mail: $email\n

    comments: $comments";

    $headers = "From: $email\r\n";

    $headers .= "BCC: gustin@BlahBlah.com\r\n";

     

    mail($to,"Comments From $Name", $message, $headers) ;

    echo "\n\n\n\n\n\n\n                    . . . . . Thank-you for you Inquiry <br>                    Some one will contact you shorlty";

    //header( "Location: /thankyou.html" );

    ?>

  2. I want to preset variables in case users leave certain fields blank in a html form
    eg $email='myname@mydomain.com';
    then php has the following:
    $Email=$_POST['Email'];
    echo "Email : ".$Email."<p>";
    if the user leaves the field empty, I want it to echo
    [color=red]Email: myname@mydomain.com[/color]
    BUT
    it does this -->
    [color=red][font=Verdana]Email:          [/font][/color]
    (ie nothing)
    soooooooooo, am I stuck doing a IF test for each post?
    that is, if post is empty, then set the variable to the desired default value?

  3. small MySQL DB => only three rows (ID, GroupID, title, MSG, etc)
    The Group ID is unique
    I have a php file that prints a table based on the fields
    this php file checks on a time schedule to see if the ID has changed
    (no change - no display // new ID = new display)
    easy when I made a NEW post (Insert) to table (ie ID was auto-increment)

    what "trick" can I do when doing Update? without making the user place a NEW value somewhere?

  4. [quote author=AndyB link=topic=106640.msg426659#msg426659 date=1157220789]
    ASC = ascending order, so the first one would be the [i]lowest[/i] number.
    [/quote]

    understood - guess that means the whole array was 'analyzed' [i]BEFORE [/i] it was fetched (ie in the DB))
    I would have guess it had to be 'fetched'  [i]before  [/i]it was analyzed

    no matter - as long as it us understood -thanks again
    ps
    GREAT forum !!!!!!!!!!
  5. well _ tried it
    still made 2 tables
    then I changed the [i]order by GroupID ascii[/i] to
    [i]order by id asci [/i] (thinking GroupID (which is a text string) does not vary between like rows)

    any other guesses?
    ps
    looked up the string => "$row = MySQL_fetch_assoc"
    seems to return a row, not an array?
    guess that is good?

    also
    I do not understand his suggestion ==>

    [quote]if that issnt enough you can also limit the amount of information seen.

    limit 1

    or 1 - 3231231323 what ever ok.[/quote]

    thanks

  6. I have a small DB (id, groupID, title, MSG , etc)
    I have 2 forms of input (via html form = Both work as desired)
    one form does edit any field in GroupID
    one form does add a new row (can put in any GroupID)
    [[[1st question - as of now - I have only 3 different GroupID possibilities
    how do I ensure the user does not have a typo and make a new (ie 4th GroupID)
    I do no want to use radio or drop down - because I do not want the users to see the 'names' of the other groups]]]

    2nd question:
    here is the hard part (for me)
    I have a small php page that prints a table using the field values in the DB
    the ROW it picks is GroupID dependent
    it works GREAT // Except when there are TWO (2) rows with the SAME GroupID
    so . . . .
    how do I just select the row that is MOST recent
    (ie had highest id# (which is auto increment)
    and yes, if there are 2 rows with the same GroupID
    I get 2 tables (only want 1)
    The value of 'pick1' is determined by a small html radio form with 3 choices
    (one for each GroupID)
    I imagine the code to fix this is simple - but I have not deduced it yet
    thanks


    [code]<?php

    include 'loginSTSAlertDB.php';

    $like=$_POST['pick1'];
    $server = MySQL_connect($host, $username, $password) or die(MySQL_error());
    $connection = MySQL_select_db($database, $server) or die (MySQL_error());

    $result = MySQL_query("SELECT * FROM Alert Where GroupID like '$like' ") ;
    while($row = MySQL_fetch_array( $result )){


    echo "    <table border=1 cellspacing=2 cellpadding=2 height=240>";
    echo "    <tr height=60>";
    echo "    <td colspan=3>" ;
    echo "    <IMG SRC=$row[Logo]>";
    echo "    </td>";
    echo "    </tr>";

    echo "    <tr>";
    echo "    <td colspan=3>";
    echo "    $row[Title]";
    echo "    </td>";
    echo "    </tr>";

    echo "    <tr>";
    echo "    <td colspan=3>";
    echo "    $row[MSG]";
    echo "    </td>";
    echo "    </tr>";

    echo "    <tr>";
    echo "    <td>";
    echo "    OK";
    echo "    </td>";
    echo "    <td>";
    echo "    <A HREF=\"http://www.".$row[MsgURL]."\" target=_blank>More</A>";
    echo "    </td>";
    echo "    <td>";
    echo "    Later";
    echo "    </td>";

    echo "    </tr>";

    echo"</table>";
    }[/code]
  7. tried suggestion both "inline" and via "css class"
    the row spacing is not as bad as in my example
    in fact, it looks a bit like the spacing here in this post
    but I have another section of my web page
    that has even 'tighter' row spacing that I am trying to emulate
  8. everyting is fine
    but I want to minimize the row height (spacing between rows output)
    so the output is as TIGHT as if I were using "shift returns" in a single cell
    I am using styles with padding and margins set to zero

    eg

    name amount
    me      10
    him      20

    not displayed as now:
    name amount

    me      10

    him      20
  9. I do not like the forced format of dates
    xxxx-xx-xx
    (can this be changed?)

    so I made the date field = varchar
    I am the only "forms entry person" for our club
    and we print out the dues monthly on a php web page
    in reverse order (of date)

    eg
    10 membername 1 jul 18
    11 membername 2 jul 17
    15 membername 3 jul 12
    12 membername 4 jul 04

    ergo = I enter the 'date' field in my html forms as jul 4, etc
    but the 'order by' does not work as desired

    hints?

    ps
    when I did a sample ["order by" paid] (ie $)
    it listed them as desired (ie my syntax is ok - just not for the varchar field for date)
  10. made a very simple DB
    1st table = no problem posing with html form => php => musql table
    made 2nd table = cannot insert data
    get his error message:
    [color=red]posting of display test data I cannot connect to the database because: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''test1.test1table2' (first,last,age)VALUES ('greg', 'gustin', '99')' at line 1[/color]
  11. [quote author=criticalsystems link=topic=100261.msg395561#msg395561 date=1152676914]
    you do not have to have a variable for ever column you can just specify the cols that you are going to give values for in the SQL statement.

    eg INSERT into table (col1,col2,col3) values (col1val,col2val,col3val);
    [/quote]

    this (your suggestion) worked Great
    too bad the original code I practiced with did not have the "columns id's" in them as did your example
    now each new submit has its 'ID' field auto increment in my table :)

  12. [quote author=hackers link=topic=100261.msg395547#msg395547 date=1152673627]
    Last solution, try to use wamp -> http://www.wampserver.com/en
    You just put "localhost" and it will be working.

    [code]MySQL_connect("localhost", "root","")or die(MySQL_error());
    MySQL_select_db("database-name-here") or die(MySQL_error());[/code]
    [/quote]

    hehe
    I am already using wamp server :)
    anyway got it just about working
    had to add another field called ID
    but I had to hard code the value to make it work and have to increment it by hand
    [code]$id=7;[/code]
    I am sure there is some code to make it do that automatically

    the real purpose of this exercise is to allow web site visitors the option of checkig off check boxes
    and therfore = every field will not be 'filled'
    will that be a problem?


  13. I added the 'or die' after each line as suggested and got this after I hit submit

    [i]I cannot connect to the database because: Column count doesn't match value count at row 1[/i]

    my table has 4 fields, (id, name, email and location)
    'id' is auto increment = so I did not put that field name in my php file
    should I?
    and if so, how should I edit my insert values code?

  14. [quote author=hackerkts link=topic=100261.msg395533#msg395533 date=1152669104]
    Change:
    [code]MySQL_connect("localhost:/MySQL/data/test1", "root", "")or die ('I cannot connect to the database because: ' . MySQL_error());[/code]
    To
    [code]MySQL_connect("localhost", "root", "")or die ('I cannot connect to the database because: ' . MySQL_error());[/code]
    [/quote]

    well - this was my 1st try - and it did not work
    thanks anyway

    hmm
    as local host =
    c:\wamp\www
    and MySql is up a level then down
    eg
    c:\wamp\MySql
    how does the connect command know where to find the DB?
    should I copy it 'under' the localhost folder somewhere?
  15. I am brand new at this
    ok with HTML // learning PHP
    trying the most SIMPLE tests for my self
    made at DB using phpMyAdmin installed on my PC (WinXP)
    c:\wamp\mysql
    c:\wamp\php
    c:\wamp\phpMyAdmin
    and
    c:\wamp\www = localhost
    (ie i put my index.html in that folder and 'surf' to localhost and all is fine :) )
    I put this file in same directory (eg my2.html)
    and surf to  [http://localhost/my2.html ]
    and it looks ok
    here is html file
    [code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <title>Untitled</title>
    </head>
    <body>
    <form action="process.php" method="post">
    Your Name: <input type="text" name="name"><br>
    E-mail: <input type="text" name = "email"><br>
    Location: <input type="text" name = "location"><br>
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>
    [/code]

    and here is the code for process.php
    [code]<head>
    <title>Untitled</title>
    </head>
    <body>
    <?php
    $name=$_POST['name'];
    $email=$_POST['email'];
    $location=$_POST['location'];
    MySQL_connect("localhost:/MySQL/data/test1", "root", "")or die ('I cannot connect to the database because: ' . MySQL_error());
    MySQL_select_db("test1");
    MySQL_query("INSERT INTO `test1table` VALUES ('$name', '$email', '$location')");
    Print "Your information has been successfully added to the database.";
    ?>
    </body>
    </html>[/code]

    it also appears ok in browser
    I get this as echo on screen (ie NOT the error message)
    [b]Your information has been successfully added to the database.[/b]

    I am guessing the problem is in the HOST field above in the 'msql_connect' line
    and yes - there is a DB called "test1" and a table called "test1table.frm"
    which is a folder called test1 which is in the data folder (as above)

    I have been reading tutorials for hours
    they say DB "locations" (and something about 'socks' :P )
    so = what is syntax for my location???

    2nd question - as this is not working = why does it show the 'success' echo when I submit the data?
    (I open the DB using phpMyAdmin and there are no new data rows)

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.