Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
bakura said:
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. :P

Mithras

Mithras Avatar

****
Studio Member

600


July 2006
Ugh... I'm trying to make a section of code that allows people to post new entries.... and it's not working :P 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!

lucifer said:
"Behold: me! I have authority in this building."

Llanilek

Llanilek Avatar
Former Elite Mod

****
Dedicated Studio Member

931


October 2005
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')';

Mithras

Mithras Avatar

****
Studio Member

600


July 2006
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!

lucifer said:
"Behold: me! I have authority in this building."

Llanilek

Llanilek Avatar
Former Elite Mod

****
Dedicated Studio Member

931


October 2005

$sql = "INSERT INTO `blogdb` (`user`, `name`, `content`, `date`, `title`) VALUES ('$user', '$name', '$content', '$date', '$title')";

$sql = mysql_query($sql);


Mithras

Mithras Avatar

****
Studio Member

600


July 2006
YAY IT WORKS!

Thanks a million!


Support Rob Scuderi, the #1 Penguins Defender!

lucifer said:
"Behold: me! I have authority in this building."

Llanilek

Llanilek Avatar
Former Elite Mod

****
Dedicated Studio Member

931


October 2005
glad it works

hows this going btw?

Mithras

Mithras Avatar

****
Studio Member

600


July 2006
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!

lucifer said:
"Behold: me! I have authority in this building."

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
mithras said:
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.

Eric

Eric Avatar



1,442


November 2005
cddude229 said:
bakura said:
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. :P
Ewww :P

You know you can do something like:
where comment.blog_id = blog.id

right?

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
eric said:
cddude229 said:


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. :P
Ewww :P

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. :P I don't know.)

Eric

Eric Avatar



1,442


November 2005
cddude229 said:
eric said:
Ewww :P

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. :P 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.

newBookmarkLockedFalling