Re: why doesn't this add
| From: | Justin French | Date: | Sun, 25 May 2003 23:56:56 +0000 |
| Subject: | Re: why doesn't this add | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148941@lists.php.net to get a copy of this message | ||
This is what I use:
$sql_query = "INSERT INTO tshirts VALUES ('' ,
'{$_POST['mylink']}')";
Justin French
on 26/05/03 11:50 AM, David McGlone (david@edificationweb.com) wrote:
> Hi all,
>
> Why is this code not adding the text in the textbox into the database:
> I've tried everything like $_POST['mylink'], '$_POST['mylink']
> ',
> "$_POST['mylink']"
>
> I can say that '$_POST['mylink'] ' adds a record into the database, but
> it's a
> blank record.
>
>
> echo("<form action=\"addtodb.php\" method=\"POST\">"
> ."<input type=\"text\" name=\"mylink\"
> maxlength=\"50\"><br>"
> ."<input type=\"submit\" value=\"add link\"><br>"
> ."</form>");
>
> $host = "localhost";
> $user = "xxxxxx";
> $pass = "xxxxxxxxxxxxxxxx";
>
>
>
> //make our connection details
> $connection = mysql_connect("$host" , "$user" , "$pass")
> or die ("Cannot make the connection");
> //connect to sampledb with our connection details
> $db = mysql_select_db("addtodb" , $connection)
> or die ("Cannot connect to the database");
>
> //insert the text box data into the sample table
> $sql_query = "INSERT INTO tshirts VALUES ('' ,
> '$_POST['mylink']')";
> $result = mysql_query($sql_query);
>
> Thanks,