> I have a query whenever I try to insert something into a mysql table. This is
> the code I am using:
> <?
>
> $host1 = gethostbyaddr("$REMOTE_ADDR");
> $date = date("Y-m-d h:i:s");
> $link = mysql_connect("$host", "$user", "$passwd");
> mysql_select_db("$database", $link);
> $sql = "INSERT INTO vcstats VALUES('', $SCRIPT_NAME, $date, $HTTP_USER_AGENT,
> $BName, $BVersion, $BPlatform, $REMOTE_ADDR, $host1)";
> $result = mysql_query($sql) or die("query error<Br>" . mysql_error());
> mysql_close();
>
> ?>



Robby,

Queries are the term used to describe all interactions with a db - that's why the 
function is called
mysql_query.
It would be helpful if you told us the error message you are receiving.

As a matter of style, it would also help you if you checked the response from each 
function call, or at least
echo-ed it so that you could see the returned information. In that case, you would see 
that processing doesn't
get as far as the INSERT operation before failing, and would be able to focus on 
working out a solution from the
manual/your guiding text.

Assuming you define the PHP variables $host, $user, $passwd, and $database, somewhere 
earlier in the script,
then the most likely problem is that they are enclosed within quotation marks inside 
the mysql_connect() and
mysql_select_db() calls. Quotation marks are only required if string literals are 
being specified.

Come back to us if that doesn't do the trick,
=dn



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to