/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] I’m having a parse error while trying to make an update to the db and using mkdir()

Okay So here’s my code that right now functions

[code=php]if ((isset($_POST[“MM_insert”])) && ($_POST[“MM_insert”] == “formInsertCollection”)) {
$insertSQL = sprintf(“INSERT INTO jmsgallery_collections (name, `description`, `path`) VALUES (%s, %s, %s)”,
GetSQLValueString($_POST[‘name’], “text”),
GetSQLValueString($_POST[‘description’], “text”),
GetSQLValueString($_POST[‘path’], “text”));
mkdir(“../gallery/success”, 0700);[/code]

What it does is does the update + creates a folder named success. I used the name success just to test out my idea, ’cause I wasn’t quite sure where to put the mkdir.

Now this is what I really need to do. I need to pull that path and replace success with it. So I tried this:

[code=php]if ((isset($_POST[“MM_insert”])) && ($_POST[“MM_insert”] == “formInsertCollection”)) {
$insertSQL = sprintf(“INSERT INTO jmsgallery_collections (name, `description`, `path`) VALUES (%s, %s, %s)”,
GetSQLValueString($_POST[‘name’], “text”),
GetSQLValueString($_POST[‘description’], “text”),
GetSQLValueString($_POST[‘path’], “text”));
mkdir(“../gallery/”$_POST[‘description’]””, 0700);
[/code]

But, I’m not entirely sure how to format it because it keeps coming up with this error: [22-Feb-2008 16:21:31] PHP Parse error: parse error, unexpected T_VARIABLE in /TEST/JMS_Software/JMSGallery/admin/functions/photos-collections-new.php on line 42. Line 42 is the mkdir.

Any ideas on how to fix my idea? Or if I’m approaching it the completely wrong way? lol

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@cinematic_jesiauthorFeb 22.2008 — Oops I made a mistake:

I tried making the php pull this -- my bad typing error:
[code=php]mkdir("../gallery/"$_POST['path']"", 0700); [/code]

Sorry 'bout that. So how do I fix the formatting on that so it parses correctly?
Copy linkTweet thisAlerts:
@cinematic_jesiauthorFeb 22.2008 — Okay now I did this and it kinda works

I declared the variable:
[code=php]$path = GetSQLValueString($_POST['path'], "text");[/code]

And then created the mkdir():
[code=php]mkdir('../gallery/'.$path.'', 0777);[/code]

It does capture the info from the form, and create a folder but it creates it with the ' ' around it. For example: 'folder'.

How do I get it so it doesn't add those ' ' around it?
Copy linkTweet thisAlerts:
@ZnupiFeb 22.2008 — [code=php]mkdir("../gallery/"$_POST['path']"", 0700); [/code][/QUOTE]

Your error is clear: you forgot to put "." before and after $_POST['path']. Try this:

[code=php]mkdir("../gallery/" . $_POST['path'], 0700);[/code]


And about the '' around the folder name, that all depends on what GetSQLValueString returns. If the value it returns is enclosed with quotes.. the folder name will be enclosed by quotes. Also, your problem was not declaring the variable so you can lose that ?
Copy linkTweet thisAlerts:
@cinematic_jesiauthorFeb 22.2008 — Oh gosh, durr, I even did that in my second way. Aha

Thanks so much! You've relieved a headache! =]
×

Success!

Help @cinematic_jesi 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.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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