kodie
Members-
Posts
17 -
Joined
-
Last visited
Never
Everything posted by kodie
-
ooops. needed to escape backslash. try that. i just tested it and it works. Works perfect! Thanks a bunch!
-
Thanks for the reply, That doesn't return anything, even tried print_r($matches); and it's empty.
-
Hey guys, I've got a little problem that I can't seem to find the answer to... I have a string like this: $oldstring = "<test1>here is some text</test1>"; and what I want to do is get "test1" and "here is some text" into 2 separate strings kind of like this: $newstring[0] = "test1"; $newstring[1] = "here is some text"; I figured I'd use preg_replace to do this but no luck. I know the answer has to be something simple but I just can't figure it out. Thanks for any help you can give!
-
oh! i was typing something wrong when testing it. Everything works perfectly as intended. Thanks again!
-
JACK POT! thank you very much, that was the ticket. Ok now i have another question if you don't mind helping me further: I'd like to be able to search for multiple tags using that method. i.e: "?id=blog&tags=test,site news" would give me results that have both of those tags regardless of what order they are in. Any ideas?
-
JACK POT! thank you very much, that was the ticket.
-
That doesnt work either. Still only shows results that have exactly what you searched for. i.e: "?id=blog&tags=test" shows items that only has the "test" tags and no other tag. "?id=blog&tags=test,news" shows items that have both the "test" and "news" tags in that order and no other tags. Why are you storing tags in a comma separated string? I figured it was the easiest way. Guess not so much. lol. I don't quite understand, can you explain this a little more? or send me to a link that explains?
-
This doesnt work either because the "tags" data from the mysql table is still "blog,site news" and needs to be splitted somehow. Is there a way to do that?
-
I have a mysql table set up like this: id subject body userid date time tags 1 blog subject blog body 1 11|29|2009 9|30|AM blog,site news,tech when displaying the data i want to be able to add "?id=blog&tags=blog,tech" to the url to search for multiple tags. i'm pretty close with this: if (isset($_GET['tags'])) { $tags = addslashes($_GET['tags']); $srchinfo = "WHERE tags IN ('$tags')"; }; $result = mysql_query("SELECT * FROM blogs $srchinfo ORDER BY id DESC LIMIT $offset, $rowsPerPage"); but, when using the url, it will only show up posts that have one of the tags. For example: Post1: site news, blog Post2: blog Post3: blog,site news "?id=blog&tags=blog" Only shows Post2 "?id=blog&tags=site news, blog" Only shows Post1 Anyone know what to do? Thank you.
-
ah, i see it now. thanks.
-
welp i ended up fixing her myself. Here's the code that worked just incase anyone wanted to know: $permissions1 = split("\|", $_SESSION['permissions']); foreach ($permissions1 as &$perm) { $permissions2 = split(":", $perm); if (isset($permissions2[1])) { $permissions[$permissions2[0]] = split(",", $permissions2[1]); } else { $permissions[$permissions2[0]] = Array("null"); } } which gives me this array: Array ( [blog] => Array ( [0] => edit_all [1] => delete_all ) [users] => Array ( [0] => edit_all [1] => delete_all ) [settings] => Array ( [0] => null ) ) thanks anyways. EDIT: if anyone cantell me how to mark as solved i will do that as well.
-
here it is: $permissions1 = split("\|", $_SESSION['permissions']); $i = "0"; foreach ($permissions1 as &$perm) { $permissions2 = split(":", $perm); $permissions_a[$i] = $permissions2[0]; $permissions_a[$i] = split(",", $permissions2[1]); $i++; } and it outputs the array like this: Array ( [0] => Array ( [0] => edit_all [1] => delete_all ) [1] => Array ( [0] => edit_all [1] => delete_all ) [2] => Array ( [0] => ) )
-
ok so i have a string that looks like this: blog:edit_all,delete_all|users:edit_all,delete_all|settings and i want to make a code that can take that string and put it in a multi-layered array like this: Array ( [0] => blog ( [0] => edit_all [1] => delete_all ) [1] => users ( [0] => edit_all [1] => delete_all ) [2] => settings ) i've googled and everything and cant seem to get anything to work. ive come close but not quite. any ideas? thank you.
-
[SOLVED] Problem: retrieving strings from a separate file.
kodie replied to kodie's topic in PHP Coding Help
PFMaBiSmAd, your a genious. I removed the showpage() code to see if that would work and sure enough it did. Now the reasoning behind the whole showpage() function was in user_auth.php it detects if the user is logged in or not. If the user is not logged in, it displays a message. If the user is infact logged in, it calls the showpage() function, which, shows the page. Heres what's inside of user_auth.php: <? $restricted_pages = array( "usercp/users" => "1", "usercp/users/edit" => "1", "usercp/users/delete" => "1", ); if (!isset($_COOKIE["logininfo"])) { echo $_TXT_NOTLOGGEDIN; //If cookie does not exsist, then the user is not logged in, show message. } else { if ($_COOKIE["logininfo"] !== "") { $logininfo = split(":", $_COOKIE['logininfo']); //If user is logged in, split up cookie info "user:pass". //Connect to database. mysql_connect("localhost", "kodieg", "pass") or die(mysql_error()); mysql_select_db("kg_usersystem") or die(mysql_error()); $row = mysql_fetch_array(mysql_query("SELECT * FROM user_data WHERE name='$logininfo[0]'")) or die(mysql_error()); if ($logininfo[1] == $row['pass']) { //Check if password is correct. if (array_key_exists($_GET['id'], $restricted_pages)) { //Check if current page is restrcited to certain users only. if ($row['type'] == $restricted_pages[$_GET['id']]) { //If current page is restricted, make sure user has the authroity to view it. showpage(); //If user has authroiry to view the restricted page, allow it. } else { echo $_TXT_RESTRICTED; //If user does not have authroirty to view the restricted page, deny it and show message. }; } else { showpage(); }; //If page is not restricted, show it to any user. }; } else { echo $_TXT_NOTLOGGEDIN; }; //If the cookie exsists, but is blank, then the user is not logged in, show message. }; ?> My next question is, in your opinion, what would be the best way to change this code so that i do not have to use the whole showpage() way? -
[SOLVED] Problem: retrieving strings from a separate file.
kodie replied to kodie's topic in PHP Coding Help
That's really werid... I'm not browsing directly to the users.php file and there isn't really anything that i haven't posted. Do you think it could be that i'm using WampServer? I don't actually have any webspace so i use WampServer so that i can still code php on my computer. -
[SOLVED] Problem: retrieving strings from a separate file.
kodie replied to kodie's topic in PHP Coding Help
includes/strs.php does have php tags. and are lines 1 through 18 in pages/usercp/users.php: <? include("user_auth.php"); function showpage() { ?> <div align="left"><? include("user_nav.php"); ?></div> <br><br> <b>Current Users:</b><br><br> <table> <tr><th>Username</th><th>User Type</th><th><th></tr> <? echo $_TXT_NOTLOGGEDIN; //Connect to database. mysql_connect("localhost", "kodieg", "pass") or die(mysql_error()); mysql_select_db("kg_usersystem") or die(mysql_error()); $result = mysql_query("SELECT * FROM user_data") or die(mysql_error()); $logininfo = split(":", $_COOKIE['logininfo']); while($row = mysql_fetch_array($result)){ if ($row['type'] == "1") { $user_type = $_TXT_USRTYPE_ADMIN; }; //Find out if ($row['type'] == "2") { $user_type = $_TXT_USRTYPE_OP; }; //what type if ($row['type'] == "3") { $user_type = $_TXT_USRTYPE_NORMAL; }; //of user -
Well i have my main page that includes a page depending on the url extension (index.php?id=PAGE). but the main page also includes a file containing mostly all the text strings being used in the sub pages. If i haven't lost you yet, here's a breakdown of it all: includes/strs.php (Contains all strings being used on other pages.) pages/main.php (Page that is included by index.php) pages/usercp/users.php (Page i'm having trouble with.) index.php (Main page that includes above files. Calls pages by ?id=PAGE) Ok, so here's an example of some code in "includes/strs.php": $_TXT_NOTLOGGEDIN = "You are not logged in. Click <a href=\"?id=usercp/login\">here</a> to log in."; $_TXT_USRTYPE_ADMIN = "Administrator"; $_TXT_USRTYPE_NORMAL = "User"; And here's where index.php includes the other two files: require_once('includes/strs.php'); if (!isset($id)) { $id="home"; }; $file = "pages/".$id.".php"; if (!file_exists($file)) { $file = "pages/404.php"; }; include($file); Well everything works until you try to go to a page that is in a folder inside "pages". in this case, "pages/usercp/users.php" or "?id=usercp/users.php" i get this error here: Notice: Undefined variable: _TXT_NOTLOGGEDIN in C:\wamp\www\public\kodieg\pages\usercp\users.php on line 8 Notice: Undefined variable: _TXT_USRTYPE_ADMIN in C:\wamp\www\public\kodieg\pages\usercp\users.php on line 16 Notice: Undefined variable: _TXT_USRTYPE_NORMAL in C:\wamp\www\public\kodieg\pages\usercp\users.php on line 18 I'm not sure if i'm being descriptive enough, any questions just ask, but i feel like i've tried everything. Anybody know why it's doing this? Thanks.