473,385 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

udate command SQL Error

ddtpmyra
333 100+
I have this below script and mysql didn't get thru I tried to print the sql query every things is fine it's just somehow can't update my table. What's wrong?

[PHP]
# Gather all required data
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];

# INSERT SQL query
$query="INSERT INTO contact (FirstName,LastName)
VALUES (
'{$FirstName}',
'{$LastName}'
)";

echo "$query";
# Execute the INSERT QUERY
$result = mysql_query($query, $dbLink) ;


if($result){
echo "Successful<BR>";

}
else {
echo "ERROR";
}
mysql_close();



#Close the mysql connection
mysql_close($dbLink);

[/PHP]
Nov 19 '08 #1
5 1567
pbmods
5,821 Expert 4TB
Heya, ddtpmyra.

Try checking for error this way:
Expand|Select|Wrap|Line Numbers
  1. if( mysql_errno() )
  2. {
  3.   exit(mysql_error());
  4. }
  5.  
http://php.net/mysql_errno
http://php.net/mysql_error
Nov 19 '08 #2
Dormilich
8,658 Expert Mod 8TB
there might be something wrong with the connection resource. check if $dbLink is valid.

regards
Nov 19 '08 #3
ddtpmyra
333 100+
hi pbmods,

Your syntax works I was able to catch what's my sql error is....

thanks a lot!

[PHP]if( mysql_error() )
{
exit(mysql_error());
} [/PHP]
Nov 19 '08 #4
Dormilich
8,658 Expert Mod 8TB
additional note:
another common way to catch a db error is
[PHP]mysql_query($sql) or die("DB Error " . mysql_errno() . ": " . mysql_error());[/PHP]
Nov 20 '08 #5
ddtpmyra
333 100+
Thanks Dormilich for the additional info
Nov 20 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Silvio | last post by:
Here's my update statement: UPDATE Item1 SET reviewloop = 1, currentreviewstate=5 WHERE itemid in (SELECT itemid FROM Item2) The thing is: the table Item2 DOES NOT HAVE a field called...
12
by: Rhino | last post by:
I am having an odd problem: the sqlj command on my system doesn't work. I am running DB2 (LUW) V8 (FP8) on WinXP. I haven't done an sqlj program since Version 6 of DB2 (LUW) so I checked the...
2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
0
by: Andre Azevedo | last post by:
Hi all ! I've created a .net serviced component with only one method. This method receive an ADODB.Command object and execute it. The ADODB.Command object is created in the client process. (VB...
34
by: Roman Mashak | last post by:
Hello, All! I'm implementing simple CLI (flat model, no tree-style menu etc.). Command line looks like this: <command> <param1> <param2> ... <paramN> (where N=1..4) And idea is pretty simple: ...
10
by: jimmy | last post by:
Hi again, sorry for posting two questions so close together but im working on a school project which is due in soon and running into some difficulties implementing the database parts. I have the...
25
by: dennijr | last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong heres the simplist code possible: Private Sub IExplorer_Click() a = Shell("C:\Program...
2
by: Taras_96 | last post by:
Hi everyone, I'm trying to run a number of commands stored within a sql file from within php using mysqli::query. The syntax I'm using is: source C:\data\projects\forum...
1
by: eraserwars | last post by:
I have been googeling every possible solution, but I cannot seem to fix LNK2019. My code is below, but I just cannot understand how anything related to LNK2019 from Microsoft's help center applies...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.