/    Sign up×
Community /Pin to ProfileBookmark

Why if(!mysqli_prepare($conn,$query) Fails ?

Php Folks,

Why this one doesn’t work …

[code]
if(!mysqli_prepare($conn,$query)
{
//Close Connection.
mysqli_close($conn);
die(“<pre>Mysqli Prepare Failed!n”.mysqli_prepare($conn,$query).”n</pre>”);
}
[/code]

While this one does ….

[code]
$stmt = mysqli_prepare($conn,$sql_query);
if($stmt == False)
{
//Close Connection.
mysqli_close($conn);
die(“<pre>Mysqli Prepare Failed!n”.mysqli_stmt_error($stmt).”n$sql_query</pre>”);
}
[/code]

Pretty much the same aren’t they ?
First one my own code.
Second one suggested by NogDog, if I remember correctly.

For some reason, php gives no response to this line:

[code]
if(!mysqli_prepare($conn,$query)
[/code]

to post a comment

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 30.2020 — Well...it's missing a closing ) for one thing. Also, since you're not assigning the result to anything, you'll be unable to do anything with it after that.
Copy linkTweet thisAlerts:
@developer_webauthorMay 31.2020 — @NogDog#1618976

Thanks. I fixed it. But that wasn't the original problem why that code wasn't working. However, I failed to reproduce the error this time.

New problem now NogDog.

I can't remember what I changed last night that is making the following code malfunctioning. Can you see if you can spot any typos ?

Continuing here now ...

https://www.webdeveloper.com/d/390112-why-mysqli-prepare-failed
Copy linkTweet thisAlerts:
@NogDogMay 31.2020 — > @developer_web#1618988 I can't remember what I changed last night that is making the following code malfunctioning.

A good reason to use Git or another software versioning solution.

Also a good reason to modularize your code into concise, focused functions instead of mutli-hundred line files of stream-of-consciousness code.
×

Success!

Help @developer_web 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 4.26,
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,
)...