|
you shouldn't have long variable names... if its more than one word to identify a variable name used more than once but is for a different thing like ID it should be $p_id; $t_id; I do something similar to that for my MySQL tables because of overlapping usage of terms (like time and id). c_id // Comment id b_id // Blog id c_time // Comment time b_time // Blog time etc.
|
|
|
|
|
Ugh... I'm trying to make a section of code that allows people to post new entries.... and it's not working Here's the code: $user = $_POST['user']; $name = $_POST['name']; $content = $_POST['content']; $date = date('F-j-S-Y-g-m-A'); $title = $_POST['date']; $sql = 'INSERT INTO `blogdb` (`user`, `name`, `content`, `date`, `title`) VALUES ($user, $name, $content, $date, $title)'; if(!$sql) { echo 'An error has occurred. Please try again later.'; } else { echo 'Entry successfully added'; }
And here's the code that displays the form: echo '<font size="4">Post</font><br /><br /><form name="postForm" method="post" action="index.php?action=post">'; echo 'Username: <input type="text" size="20" maxlength="16" name="user" /><br />'; echo 'Display Name: <input type="text" size="20" maxlength="16" name="name" /><br />'; echo 'Content: <br /><textarea rows="8" cols="40" name="content"></textarea>'; echo '<input type="hidden" name="date" value="' . time() . '" /><input type="hidden" name="post" value="1" />'; echo '<br /><input type="submit" value="Post" /></form>';
Last Edit: Oct 28, 2006 14:48:40 GMT by Mithras
|
Support Rob Scuderi, the #1 Penguins Defender!
"Behold: me! I have authority in this building."
|
|
|
|
quote your values
change this
$sql = 'INSERT INTO `blogdb` (`user`, `name`, `content`, `date`, `title`) VALUES ($user, $name, $content, $date, $title)';
to this
$sql = 'INSERT INTO `blogdb` (`user`, `name`, `content`, `date`, `title`) VALUES ('$user', '$name', '$content', '$date', '$title')';
|
|
|
|
|
Then it's saying unexpected T_VARIABLE. I tried escaping the strings, using the little `, and taking the quotes off the ends of the query.
|
Support Rob Scuderi, the #1 Penguins Defender!
"Behold: me! I have authority in this building."
|
|
|
|
$sql = "INSERT INTO `blogdb` (`user`, `name`, `content`, `date`, `title`) VALUES ('$user', '$name', '$content', '$date', '$title')";
$sql = mysql_query($sql);
|
|
|
|
|
|
glad it works
hows this going btw?
|
|
|
|
|
I got that working, but I really haven't had time to go much further. We're nearing the end of the semester, and all the teachers are really pushing to get everything done
|
Support Rob Scuderi, the #1 Penguins Defender!
"Behold: me! I have authority in this building."
|
|
|
|
I got that working, but I really haven't had time to go much further. We're nearing the end of the semester, and all the teachers are really pushing to get everything done You should try getting yourself banned from all the forums you frequent. Works well for me.
|
|
|
|
|
you shouldn't have long variable names... if its more than one word to identify a variable name used more than once but is for a different thing like ID it should be $p_id; $t_id; I do something similar to that for my MySQL tables because of overlapping usage of terms (like time and id). c_id // Comment id b_id // Blog id c_time // Comment time b_time // Blog time etc. Ewww You know you can do something like: where comment.blog_id = blog.id right?
|
|
|
|
I do something similar to that for my MySQL tables because of overlapping usage of terms (like time and id). c_id // Comment id b_id // Blog id c_time // Comment time b_time // Blog time etc. Ewww You know you can do something like: where comment.blog_id = blog.id right? Yep. To compare data, but does it work that way in an associative array? (mysql_fetch_assoc)? (And I'm serious about asking. I don't know.)
|
|
|
|
|
Ewww You know you can do something like: where comment.blog_id = blog.id right? Yep. To compare data, but does it work that way in an associative array? (mysql_fetch_assoc)? (And I'm serious about asking. I don't know.) There are workarounds that can lead you to the same result. You know what I just noticed that's really weird, as I type my mouse moves across the screen in one direction and changes directions and starts going back the other way. Really wacky.
|
|
|