Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Ensuring records are written to the MySQL database
Is there any basic, sure fire 'if - else' script that will ensure that
records entered into my form will actually be written to the database?
I noticed when debugging one day that records would show up when using
the print command as though they'd been entered but hadn't actually
been written to the database.  I'm hoping to find some sort of if/else
script that can be easily used with 'insert into' in my PHP.  Am using
MySQL 4.1.11nt and PHP 5.04

A sample code I'm working on...
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to
database"); // make connection to database
mysql_select_db($DBName) or die("Unable to select database $DBName");
// select database
if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database.  Please report this
problem';
exit;
}
$sqlquery = "INSERT INTO $table VALUES('$id', '$money', '$treats',
'$date')";
$results = mysql_query($sqlquery);
mysql_close();

TIA for any help.

Report this thread to moderator Post Follow-up to this message
Old Post
cover
05-07-05 08:55 AM


Re: Ensuring records are written to the MySQL database
Yes. I can't tell if you're using mysql or mysqli so first pick one and
then use one of the following:

http://php.net/manual/en/function.m...fected-rows.php
http://php.net/manual/en/function.m...fected-rows.php


Report this thread to moderator Post Follow-up to this message
Old Post
Philip Olson
05-07-05 01:56 PM


Re: Ensuring records are written to the MySQL database
Isn't mysqli the one that is preferred?  If so, I'll probably just use
that one exclusively.  Thanks very much guys - appreciate your
replies.


On 6 May 2005 23:45:53 -0700, "Philip  Olson" <philipolson@gmail.com>
wrote:

>Yes. I can't tell if you're using mysql or mysqli so first pick one and
>then use one of the following:
>
>http://php.net/manual/en/function.m...fected-rows.php
>http://php.net/manual/en/function.m...fected-rows.php


Report this thread to moderator Post Follow-up to this message
Old Post
cover
05-11-05 08:58 AM


Re: Ensuring records are written to the MySQL database
mysqli is used in php5 ONLY

> Isn't mysqli the one that is preferred?  If so, I'll probably just use
> that one exclusively.  Thanks very much guys - appreciate your
> replies.



Report this thread to moderator Post Follow-up to this message
Old Post
Peter
05-11-05 08:58 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP SQL archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:39 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.