Birdman203
-
Posts
24 -
Joined
-
Last visited
Never
Posts posted by Birdman203
-
-
[code]
$count_session = count($_SESSION['topics']);
$id = $_GET['id'];
$array_session = array(
'id' => $id
);
$array_session2[$count_session] = $array_session;
$set_session = $_SESSION['topics'][$array_session2];
[/code]
how come this doesnt work? or am i doin somethin wrong? -
How can I know when the user leaves the website or closes the browser?
-
dont do mysql_select_db();
on your query do mysql_db_query("db", "select..."); -
I have something like this:
[code]
<option value="1" style="padding-left: 20px; background: url(../img/flags/1.gif) no-repeat;" selected>United States</option><option value="2" style="padding-left: 20px; background: url(../img/flags/2.gif) no-repeat;" >Norway</option>
[/code]
And I need the value of it to be inserted as the ID in a table and the name of it thing which is United Stats and Norway in name.
I need this, because I have about 180 countries and I need all of them to be in a SQL database. -
Can you tell me whats wrong with this?
[code]
<?php
function quote($message) {
$quoteCount = preg_match_all("#\#(.*?)#si", $message, $quote2);
for ($i = 0; $i < $quoteCount; $i++) {
if (is_numeric($quote2[1][$i])) {
$quote = $quote2[1][$i];
$result = mysql_db_query("typekill_$config[short]", "select * from cp_fposts where topic_id = '$_GET[id]' order by id asc");
$n = 1;
$b = 0;
while ($row = mysql_fetch_array($result)) {
$array[$b] = array(
'id' => $qry[id],
'post_num' => $n,
'author' => $row[author],
'message' => $row[message]
);
$n++;
$b++;
}
for ($d = 0; $d < count($array); $d++) {
if ($array[$d]['post_num'] == $quote) {
$author = mysql_db_query("typekill_global", "select * from cp_members where member_id = '$array[$d][author]'");
$qry = mysql_fetch_array($author);
$message = preg_replace("/\#{$quote}/si", '<table cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#A9A8AE\" width=\"85%\" style=\"margin: 4px auto 8px auto;\"><tr style=\"background-image: url(images/oddrowbg.gif);\"><th style=\"padding-left: 5px; text-align: left;\"><b>#{$quote} by <a href=members.php?mode=profile&id={$qry[member_id]}>{$qry[alias]}</a></b></th></tr><tr bgcolor=\"{$config.color}\"><td style=\"padding-left: 6px;\" valign=\"top\">{$array[$d][message]}</td></tr></table>', $message);
}
}
}
}
return($message);
}
?>
[/code] -
Delete the {} around $_SESSION['username']['user']
-
OK, now I have another question. Didn't know if I should make a new topic or not.
Lets say I have this array:
[code]
Array (2)
0 => Array (11)
id => "18",
post_num => "1",
message => "news post #7<br />\r\n<img src=http://g..."
1 => Array (11)
id => "19",
post_num => "2",
message => "gagaga"
[/code]
And now I need to get the "message" from it where the post_num is 1.
-
Nice, thank you it works now.
-
Just bumping the topic.
-
Ok so this is what I did to test it:
[code]
<?php
require('required.inc.php');
$message = "[[member:Birdman]]<br>sada<br>[[member:ZOiD]]";
echo member($message);
function member($message) {
$prepareCount = preg_match_all("#\[\[member:(.*?)\]\]#si", $message, $prepare);
for ($i = 0; $i < $prepareCount; $i++)
{
$alias = $prepare[1][$i];
$result = mysql_db_query("typekill_global", "select * from cp_members where alias = '$alias'");
$row = mysql_fetch_array($result);
$message = preg_replace("/\[\[\member:(.*?)\]\]/si", "<img src=http://global.typekill.net/flags/{$row[country]}.gif> <a href=members.php?mode=profile&id={$row[member_id]}>{$row[alias]}</a>", $message);
}
return($message);
}
?>
[/code]
And this is what I got:
[code]
<img src=http://global.typekill.net/flags/55.gif> <a href=members.php?mode=profile&id=1>Birdman</a><br>
sada<br>
<img src=http://global.typekill.net/flags/55.gif> <a href=members.php?mode=profile&id=1>Birdman</a>
[/code]
But when you do print_r($prepare); everything is in the array the right way and stuff so I don't know whats wrong. -
header('Location: url');
-
$prepareCount returns the number just like if you would do it with count. I did print_r($prepareCount); and it returned 2 not an array. $prepare is an array not $prepareCount. The problem is that $i++ isn't executing or somethin, because it always stays at 0. I inserted $i before <img and both were 0, but the 2nd 1 was supposed to be 1. That is why this is not workin and I do not know how to fix it that's what I'm asking for. If any of you know how to fix this.
-
Does any one know?>
-
I did this here look through it and learn!
[code]
<?php
require 'required.inc.php';
$news = $config[news];
$page = $_REQUEST['page'];
$mul2 = bcmul($page, $news);
$mul = bcsub($mul2, $news);
if (isset($page)) {
$result = mysql_db_query("typekill_$config[short]", "select * from cp_ftopics where cat_id = '$config[news_cat]' order by id desc limit $mul, $config[news]");
$smarty->assign("isset", "1");
} else {
$result = mysql_db_query("typekill_$config[short]", "select * from cp_ftopics where cat_id = '$config[news_cat]' order by id desc limit 0, $config[news]") or die(mysql_error());
$smarty->assign("isset", "0");
}
$count = mysql_num_rows($result);
if ($count > $mul) {
if (isset($page)) {
$nextp = $page + 1;
} else {
$nextp = $page + 2;
}
$smarty->assign("nextp", $nextp);
}
if ($count < $mul) {
$backp = $page - 1;
$smarty->assign("backp", $backp);
}
?>
[/code] -
Does anyone know what can be wrong with it?
-
When I did that it like doesn't execute, because it doesn't even replace the [[member:Birdman]] or [[member:ZoID]]
EDIT: It's fine how it was before, but the $i++ doesn't execute. Even if I put it at the end below $message. -
I don't know why, but this doesn't work. the $i always stays at 0.
[code]
$prepareCount = preg_match_all("#\[\[member:(.*?)\]\]#si", $message, $prepare);
for ($i = 0; $i < $prepareCount; $i++) {
$alias = $prepare[1][$i];
$result = mysql_db_query("typekill_global", "select * from cp_members where alias = '$alias'");
$row = mysql_fetch_array($result);
$message = preg_replace("/\[\[member:(.*?)\]\]/si", "<img src=http://global.typekill.net/flags/$row[country].gif> <a href=members.php?mode=profile&id=$row[member_id]>$row[alias]</a>", $message);
}
[/code] -
I fixed it and the funny thing was I didn't have to use SESSIONS or anything like that. I just had to rewrite the line and it worked.
-
I can not figure what is wrong with this code. When it goes to index.php it shows the news the ammount of news specified by $config[news] which is 5, but when it goes to index.php?page=2 it doesn't show anything. And even the $count is set to 0, but really it's not.
Here is the code:
[code]
<?php
require 'required.inc.php';
$news = $config[news];
$page = $_REQUEST['page'];
$mul2 = bcmul($page, $news);
$mul = bcsub($mul2, $news);
if (isset($page)) {
$result = mysql_db_query("typekill_$config[short]", "select * from cp_ftopics where cat_id = '$congig[news_cat]' order by id desc limit $mul , $news") or die(mysql_error());
} else {
$result = mysql_db_query("typekill_$config[short]", "select * from cp_ftopics where cat_id = '$config[news_cat]' order by id desc limit 0, $news") or die(mysql_error());
}
$count = mysql_num_rows($result);
if ($count > $mul) {
$smarty->assign("nextp", 1);
}
if ($count < $mul) {
$smarty->assign("backp", 1);
}
$i = 0;
while ($row = mysql_fetch_array($result)) {
$result2 = mysql_db_query("typekill_global", "select * from cp_members where alias = '$row[author]'") or die(mysql_error());
$qry = mysql_fetch_array($result2);
$cresult = mysql_db_query("typekill_$config[short]", "select * from cp_fposts where topic_id = '$row[id]'") or die(mysql_error());
$row2 = mysql_fetch_array($cresult);
$comments2 = mysql_num_rows($cresult);
$comments = bcsub($comments2, 1);
$time = date("M d Y, h:i:s a", "$row[date]");
$news = array(
'id' => $row[id],
'title' => $func->outp($row[title]),
'date' => $time,
'message' => $func->outp($row2[message]),
'readmore' => $func->outp($row2[readmore]),
'author' => array(
'id' => $qry[member_id],
'firstname' => $qry[firstname],
'lastname' => $qry[lastname],
'alias' => $qry[alias],
'country' => $qry[country]),
'comments' => $comments
);
$news2[$i++] = $news;
}
$smarty->assign("main_news", $news2);
$smarty->display('index.tpl');
?>
[/code] -
[code]
<?php
$d = 0;
foreach (glob("admin_*.php") as $filename) {
$arr = array(
'file' => $filename,
'title' => "title"
);
$array[$d++] = $arr;
}
?>
[/code]
Tested it and it works. Now how do I do the title. -
is anyone looking into this?
-
These are .php files and $title is a var.
$title = "Title of the page"; -
I need a script and do not know how to make it, but it:
1. Searches through a folder and looks for files starting with [b]admin.[/b]
2. After that it reads the file and looks for $title and puts it in an array.
The array should look like so:
[code]
array (
1 (
file -> "name of file",
title -> "$title from the file"
)
2 (
file -> "name of file",
title -> "$title from the file"
)
)
[/code]
I hope you understand this
help with php + mysql
in PHP Coding Help
Posted
[code]
<?php
$_mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'view';
switch($_mode)
{
case 'newtopic':
$page = "Forums :: New Topic";
$tpl->assign('title', "$board_config[site_name] " . ":: $page");
$members->start_session($page);
$f_id = $_GET['f'];
$sql = "SELECT * FROM " . FORUMS_TABLE . " WHERE forum_id = '$f_id'";
$query = mysql_query($sql);
$num = mysql_num_rows($query);
$row = mysql_fetch_array($query, MYSQL_ASSOC);
if ( $num == "0" || empty($row['parent_id']) )
{
$tpl->assign('message', 'There is no forum with that ID.');
}
else
{
if ( $members->check_cat_per( $members->get_member_id(), 'forum_new_topic', $f_id ) == "1" )
{
if ($_POST['submit'])
{
if ( empty($_POST['title']) || empty($_POST['message']) )
{
$tpl->assign('message', 'You left the title and/or message blank.');
$tpl->assign('redirect', 'index.php?s=forums&mode=newtopic&f=' . $f_id);
}
else
{
$forum_id = $f_id;
$poster = $members->get_profile( $members->get_member_id() );
$poster_id = $poster['member_id'];
$time = strtotime("now");
$title = submit_textbox($_POST['title']);
$message = submit_textbox($_POST['message']);
$sql_auto = "SHOW TABLE STATUS " . POSTS_TABLE . "";
$query_auto = mysql_query($sql_auto);
$auto_row = mysql_fetch_assoc($query_auto);
$post_id = $auto_row['Auto_increment'];
$sql_insert_topic = "INSERT INTO " . TOPICS_TABLE . " (forum_id, poster_id, title, first_poster_id, first_post_id, last_poster_id, last_post_id, last_post_time) VALUES ('$f_id', '$poster_id', '$title', '$poster_id', '$post_id', '$poster_id', '$post_id', '$time')";
$query_insert_topic = mysql_query($sql_insert_topic);
$topic_id = mysql_insert_id();
$sql_insert_post = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, message, post_time, number_in_topic) VALUES ('$topic_id', '$f_id', '$poster_id', '$message', '$time', '1')";
$query_insert_post = mysql_query($sql_insert_post);
$num_topics = $row['num_topics'] + 1;
$sql_update_forums = "UPDATE " . FORUMS_TABLE . " SET num_topics = '$num_topics' WHERE forum_id = '$f_id'";
$sql_update_query = mysql_query($sql_update_forums);
$tpl->assign('message', 'You have succesfully made a new topic.');
$tpl->assign('redirect', 'index.php?s=forums&mode=view_topic&id=' . $topic_id);
}
}
else
{
$tpl->assign('form', '1');
$sql_parent = "SELECT * FROM " . FORUMS_TABLE . " WHERE forum_id = '$row[parent_id]'";
$query_parent = mysql_query($sql_parent);
$row_parent = mysql_fetch_array($query_parent);
$forum_data = $row_parent;
$forum_data['child'] = $row;
$tpl->assign('forum_data', $forum_data);
}
}
else
{
$tpl->assign('message', 'You do not have permission to post a topic in this forum.');
$tpl->assign('redirect', 'index.php?s=forums&mode=view_forum&id=' . $f_id);
}
}
$tpl->display('forums-newtopic.tpl');
break;
}
?>
[/code]
line 52 is
[code]
$auto_row = mysql_fetch_assoc($query_auto);
[/code]