/    Sign up×
Community /Pin to ProfileBookmark

Error Please Help

Part of code!

[code=php]<?php
if($_REQUEST[‘do’]){
$page=$_SERVER[‘PHP_SELF’];
$cxn = mysqli_connect(“localhost”, “phpworker”, “030892w”, “worker”); //Host, User, Pass, DBName
$projectName=stripslashes($_REQUEST[‘projectName’]);
if(strlen($projectName) <= 0){
header(“location: {$page}?msg=ERROR”);
}
$projectDesc=stripslashes($_REQUEST[‘projectDesc’]);
if(strlen($projectDesc) <= 0){
header(“location: {$page}?msg=ERROR”);
}
$email=stripslashes($_REQUEST[’email’]);
if(strlen($email) <= 0){
header(“location: {$page}?msg=ERROR”);
}
$owner=$_SESSION[‘user’];

$rdate=date(“D-M-Y h:i:s”);

$sql=”
INSERT INTO `projects` (`owner`, `projectName`, `projectDesc`, `ownerEmail`, `rdate`) VALUES (‘$owner’, ‘$projectName’, ‘$projectDesc’, ‘$email’ ‘$rdate’)
“;
$result = mysqli_query($cxn, $sql) or die (“There was an Error.”);
}
?>[/code]

Can someone help it just shows “There was an Error.”

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 27.2007 — First thing that jumps out at me is that it appears you are missing a comma between the last two values in your query.

To get more useful debug info, you could change the "or die" after the query to something like:
[code=php]
$result = mysqli_query($cxn, $sql) or die ("There was an Error: " . mysqli_error($cxn) . "<br>n" . $sql);
[/code]

The above is good for debugging, but you'll probably want to do some sort of error_log() for the production version rather than outputting database info to the browser should a query fail.
Copy linkTweet thisAlerts:
@bradmasterxauthorDec 27.2007 — Thanks That was the error and thanks for the debugging info.
×

Success!

Help @bradmasterx 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 5.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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