Jump to content


help


2 replies to this topic

#1 venomsnake

    Jedi In Training

  • Members
  • PipPip
  • 481 posts
  • Gender:Male

Posted 31 December 2005 - 03:14 PM

i need help on 2 different things, but they both have to deal with a news cms

1st: in the admin cp of my news, im having it so when u post a news, it puts the username of the poster, i got it working with the comments, but for some reason it doesnt work for posting the news. heres the code:

	  <div align='center'><form name='form1' method='post' action='newsadmin.php?action=add'>
	  <input size="20" type='hidden' value='<? echo $_SESSION['s_username'] ?>' name='username' maxlength='100' /><br>
	  Title:
	  <input name="title" type="text" class="textarea" id="title">
	  <br>
	  <br>
	  <input type="hidden" name="id">
	  <textarea name='newstext' cols='50' rows='10' wrap='VIRTUAL' class='textarea' id="newstext"></textarea>
	  <br>
	  <input class="textarea" type="reset" name="Reset" value="Reset">
	  <input class="textarea" type="submit" name="Submit" value="Submit">
	  </form></div><br>
Thats for the add form, and this is the insert sql
$date = time();
	$sql = mysql_query("INSERT INTO news (id,title,newstext,username,date)"."VALUES ('NULL', '$title', '$newstext', '$username', '$date')");
	header( 'refresh: 0; url=http://gamingreloaded.com/zp/news%20cms/newsadmin.php' );
What happens is that it puts the name of the database, not the username, i had this happen before, but i forgot how to fix it.

2nd: when i post the news, it puts the date automaticly, using the sql above, but even tho i posted it at 1:55PM, it says 7:55PM, it adds 6 hours.

to show the date on the news page, i put
$date = date('D, F j, Y \a\t h:i A', $r["date"] + $trow["timezone"]);

PS: the
+ $trow["timezone"])
doesnt change it

please help me, i need to get this fixed, fast

Edited by venomsnake, 31 December 2005 - 03:15 PM.


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 01 January 2006 - 12:55 AM

1. I've seen that database issue before, not on my site, but on somebody elses. Try unsetting your database username after you connect to the server and see if that changes anything.
Also, either i'm missing something, or you have register_globals on your server turned on, which is a bad thing. Your query should look more like:
$sql = mysql_query("INSERT INTO news (title,newstext,username,date) VALUES ('".$_POST['title']."', '".$_POST['newstext']."', '".$_POST['username']."', '".$_POST['date']."')") or die(mysql_error());
Note, it should really only be changed if you did leave something out in the code you posted. If the variables you used were set previously, then you can try changing it to see if it at least fixes the username problem. Also, if the page this query is used on is used by more then just you, i would recommend using mysql_real_escape_string() on the values.

2. You've already asked before. http://www.pixel2lif...showtopic=16764
$trow["timezone"] probably doesn't change because it was never set, or it is set to like +/- 5, when it should be +/- 18000 (note, 5 is a random number i pulled out of no where, 18000 is 5*3600).

#3 venomsnake

    Jedi In Training

  • Members
  • PipPip
  • 481 posts
  • Gender:Male

Posted 01 January 2006 - 02:30 AM

the problem im having with #2 is that it is putting the wrong time that the news is posted, and the time changes from the timezone when u go into the comments, idk why it doesnt work on both as its the same code.

and ill try what u said for the 1st part, thanks
edit: and it worked, thanks again

edit2: i figured out the 2nd part, but with the timezones, when u view the comments, the time chanes with the timezone, but when u view all the news, the time doesnt change, now the timezone stuff is set in the config file.
$time = "SELECT * FROM Users WHERE username='$_SESSION[s_username]'";
	$gettime = mysql_query($time) or die (mysql_error());
	$trow = mysql_fetch_array($gettime);
	$time_diff = $trow['timezone'];
and im using this
$date = date('D, F j, Y \a\t h:i A', $r["date"] + $trow["timezone"]);
like i said before, on both the comments page and the show all the news page, but the time only changes with the selected timezone on the comments page
edit: i got everything working now

Edited by venomsnake, 02 January 2006 - 05:18 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users