/    Sign up×
Community /Pin to ProfileBookmark

running query…

$date=$values3[0][0];
mysql_query(“insert into t2 values(“$values3[0][0]”)”,$conn);

when try to execute the second line.the page doesnt give error but it doesnt put any information into the database.But when I assign it to $date just like I did in the first line and then execute as :

mysql_query(“insert into t2 values(“$date”)”,$conn);

it puts the information into the database.Briefly,I wanna put information into mysql database via php by using arrays in my query.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@bokehFeb 20.2006 — Try printing out your SQL errors. It makes debugging a lot easier. [code=php]$query = "INSERT INTO t2 VALUES('{$values3[0][0]}')";
mysql_query($query,$conn) or die('Error: '.mysql_error().' -- Query: '.$query);[/code]
Also you should consider specifying the column that you want the data inserted into.
Copy linkTweet thisAlerts:
@NogDogFeb 20.2006 — <i>
</i>mysql_query("insert into t2 values("[color=red]{[/color]$values3[0][0][color=red]}[/color]")",$conn);

When you want to interpolate an array element variable within a double-quoted string, you need to use "complex variable notation": wrapping the variable within curly braces.
×

Success!

Help @guess spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...