473,473 Members | 4,185 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

insert data in mysql code

18 New Member
i want to ask, is it my coding got problem? Because when i run my program that can't be insert in mysql. cn some body let me noe my mistake?
thanks[php]
include("php_library/connect.php");
$tablename = "jcy_users";
$id = "603354";
$username = "jcy";
$password = "123";
$userlever = "staff";
$fullname = "jane";
$datecreate = date(Y."-".m."-".d);
$timecreate = date(H.":".i.":".s);
$query = "INSERT INTO ".$tablename." (id, username, password, userlever, fullname, datecreate, timecreate) VALUES ( '";
$query .= $id."', '";
$query .= $username."', '";
$query .= $password."', '";
$query .= $userlever."', '";
$query .= $fullname."', '";
$query .= $datecreate."', '";
$query .= $timecreate."')";
echo $query."<br>";
if (mysql_query($query))
{
echo "Sucess";
}
else
{
echo "Fail";
}[/php]
Apr 11 '08 #1
6 1557
rpnew
188 New Member
i want to ask, is it my coding got problem? Because when i run my program that can't be insert in mysql. cn some body let me noe my mistake?
thanks

/************************************************** **************************************/
include("php_library/connect.php");
$tablename = "jcy_users";
$id = "603354";
$username = "jcy";
$password = "123";
$userlever = "staff";
$fullname = "jane";
$datecreate = date(Y."-".m."-".d);
$timecreate = date(H.":".i.":".s);

$query = "INSERT INTO ".$tablename." (id, username, password, userlever, fullname, datecreate, timecreate) VALUES ( '";
$query .= $id."', '";
$query .= $username."', '";
$query .= $password."', '";
$query .= $userlever."', '";
$query .= $fullname."', '";
$query .= $datecreate."', '";
$query .= $timecreate."')";
echo $query."<br>";
if (mysql_query($query))
{
echo "Sucess";
}
else
{
echo "Fail";
}
/************************************************** ***********************************/

Hi,
What is your page ECHOing like... is it echoing $QUERY perfectly??
And what is the echo from if condition?

Regards,
RP
Apr 11 '08 #2
Markus
6,050 Recognized Expert Expert
I dont understand why you're writing the code in that way... ?

Just write it simple as:
[php]
INSERT INTO `tbl_name`
(`col_1`, `col_2`)
VALUES
('{$_var1}', '{$_var2}');
[/php]
Apr 11 '08 #3
ronverdonk
4,258 Recognized Expert Specialist
warning:

Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Apr 11 '08 #4
Atli
5,058 Recognized Expert Expert
Hi.

I, like rpnew, would like to see the query that is actually getting executed. The one that you print onto you page.
Does the query look like you intended?

Try using the mysql_error function if the query fails to see exactly what the problem is.
And then tell us :)
Apr 12 '08 #5
SeeMe
18 New Member
I slove my problem aldy. Thanks.
Apr 12 '08 #6
Markus
6,050 Recognized Expert Expert
I slove my problem aldy. Thanks.
How did you solve it?
Apr 12 '08 #7

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

Similar topics

15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
10
by: Python_it | last post by:
Python 2.4 MySQL-python.exe-1.2.0.win32-py2.4.zip How can I insert a NULL value in a table (MySQL-database). I can't set a var to NULL? Or is there a other possibility? My var must be variable...
1
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. ...
2
by: bballr | last post by:
I have a problem that I'm not sure if it can be done. I'm trying to use the MySQL C API to be able to use a normal sql insert statement that will send the data or file to a directory and NOT the...
5
seshu
by: seshu | last post by:
hi everybody this is seshu i am creating an application for chekin/checkouttime for that i need to insert data in to mysql for that i know the command in mysql and even how to do...
2
josie23
by: josie23 | last post by:
Egad, I'm not a coder/programmer by nature or occupation but understand things like html and css and a small amount of perl. So, basically, I'm a perl/mysql imbecile. But, I've been trying to...
2
by: blitzztriger | last post by:
Hello!! how do i insert values into mysql , after parsing a submiting textbox?? I made the arrays, so this should be a basic insertion of them in the db, but something is missing, or in the wrong...
6
by: TheRealDan | last post by:
Hi all. I'm having a problem with a special characters. I have php script that reads from an xml file and writes to a mysql db. It's a script called phptunest that I found on the net, although the...
0
by: brianrpsgt1 | last post by:
I am attempting to insert data from a HTML form using a .psp script. I can not find how to link the data that is inserted into the form to the variables in the .psp script to then insert into the...
18
by: dbdb | last post by:
hi guys, i just new in asp.net world. i have an error for my first web test. here my code : sub OnBtnSendClicked (s As Object, e As EventArgs) Dim strConn As String =...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.