Philip
Staff Alumni-
Posts
4,665 -
Joined
-
Last visited
-
Days Won
20
Everything posted by Philip
-
It strips that first ' when there is a ?> involved. Weird. <?php $string = 'Test ?>'; SMF bug, replicated on my server as well.
-
Don't assume I know that, since you didn't mention anything about it Does it print out anything for session data? A few things I'd recommend: Indent properly, or at least consistently Comment, please comment your code. Reading through it is pretty hard Try using echo's to see where exactly your code is going. (e.g. after a if statement to see which route your code went) Here's how I'd indent the code, I think it's a lot easier to read: <?php include_once("./regv3_functions.php"); if(!$_SESSION["admin"]) { echo "Access denied."; echo $_SESSION["admin"]; echo $_SESSION["uid"]; } else { echo "<h3>Welcome to the Admin Area.</h3>"; if($edit){ $edit = $_GET["edit"]; $filename = "./$edit.php"; $contents = file_get_contents("./$edit.php"); echo '<center><form action="" method="post"><textarea name="contents" rows="10" cols="50">'.$contents.'</textarea><br><input type="submit" name="save" value="Save"><input type="reset" value="Reset"></form></center>'; $save = $_POST["save"]; if($save) { $newcontents = $_POST["contents"]; file_put_contents($filename, $newcontents); echo "File has been saved."; } } $forum = $_GET["forum"]; if($forum) { $act = $_GET["act"]; $acts = array("create_cat","create_subcat"); $actions = array("create_cat" => "Create Forum Category","create_subcat" => "Create Forum Sub Category"); $x=1; $c=count($actions); foreach($actions AS $url => $link){ $pipe=($x == $c) ? "" : " $bull; "; echo "<p><a href='./index.php?page=admin&forum=1&act=".$url."'>".$link."</a> •</p>"; $x++; } if(!act || !in_array($act,$acts)) { echo "<br><p>Choose an option from above to continue.</p>"; } else { if($_GET["act"] == 'create_cat'){ if(!$_POST["submit"]){ echo "<table border=0>"; echo "<form method='post' action='index.php?page=admin&forum=1&act=create_cat'>"; echo "<tr><td>Category Name</td><td><input type='text' name='name'></td></tr>"; echo "<tr><td>Admin Only</td><td><input type='checkbox' name='admin' value='1'></td></tr>"; echo "<tr><td colspan='2' align='right'><input type='submit' name='submit' value='Create Forum Category'></td></tr>"; echo "</form></table>"; } else { $name = mss($_POST["name"]); $admin = $_POST["admin"]; if($name) { if(strlen($name) < 3 || strlen($name) > 32) { echo "The category name must be between 3 and 32 characters."; } else { $sql4 = "SELECT * FROM forum_cats WHERE `name`=".$name."'"; $res4 = mysql_query($sql4) or die(mysql_error()); if(mysql_num_rows($res4) > 0){ echo "The category name already exists!"; } else { $admin_check = ($admin == '1') ? "1" : "0"; $sql5 = "INSERT INTO forum_cats (name, admin) VALUES($name, $admin_check)"; $res5 = mysql_query($sql5) or die(mysql_error()); echo "The forum category <b>".$name."</b> has been added."; } } } else { echo "You must supply a category name!"; } } } } } ?> <br><br><br> <h3> Click on a link to edit that page. </h3> <a href="./index.php?page=admin&edit=home">Home</a> <a href="./index.php?page=admin&forum=1">Forum</a> <a href="./index.php?page=admin&edit=orderadmin">Order Admin</a> <a href="./index.php?page=admin&edit=serveradmins">Server Admins</a> <a href="./index.php?page=admin&edit=aboutus">About Us</a> <a href="./index.php?page=admin&edit=contact">Contact</a> <?php } ?> That being said, before if(!$_SESSION["admin"]) { Add in: print_r($_SESSION); and see if you see the array element "admin" and if it has the correct value set to it.
-
I think the above quote should be pretty obvious why you're getting an error. As for access denied: you need to have session_start(); after your opening php tag. Find: $sql5 = "INSERT INTO forum_cats (name, admin) VALUES($name, $admin_check)"; Insert after above line: echo $sql5; Copy/Paste the results here
-
You will get a notice warning: Notice: Array to string conversion in /path/test.php on line #
-
"one, two, three" would be from one value in the db.
-
Well, if you save a string in the DB like: "one, two, three" - explode that would get you an array ( 0 => "one", 1 => "two", 2 => "three") then implode that into something like "one - two - three" don't ask why I'd do something like that, but it's possible somebody would want to.
-
But like CV said, is it really needed to have all of those variables, or could you just select what you needed (maybe a few at a time)?
-
You could use array_slice() $string = implode(array_slice($yourArray, 1,1));
-
Putting your code in the highlighted form will show you the problems: <?php // some echo up here probably: echo " </table> <td></td><center><b>Sucess! </b><br><br>"; echo "Your URL: <br>"; if(isset($t_rows[1])) { echo "<input type=\"text\" id=\"Links\" name\"Links\" value=\"http://www.".$siteurl."/get.php?i=".$folder_id."\" class=\"txt_sucess\" onClick=\"this.form.Links.select();this.form.Links.focus()\">"; } else { echo "<a href="http://www.".$siteurl."/get.php?i=".$folder_id."\">http://".$siteurl."/get.php?i=".$folder_id."</a><br>"; } } else { echo "<center>Error!"; } } else { ?> You need to make sure to escape the quotes, or use single quotes. Here's how I would have done it: <?php // some echo up here probably: echo ' </table> <td></td><center><b>Sucess! </b><br><br>'; echo 'Your URL: <br>'; if(isset($t_rows[1])) { echo '<input type="text" id="Links" name"Links" value="http://www.'.$siteurl.'/get.php?i='.$folder_id.'" class="txt_sucess" onClick="this.form.Links.select();this.form.Links.focus()">'; } else { echo '<a href="http://www.'.$siteurl.'/get.php?i='.$folder_id.'">http://'.$siteurl.'/get.php?i='.$folder_id.'</a><br>'; } } else { echo '<center>Error!'; } } else { ?>
-
Or, done in a mysql query: SELECT IF(`field` IS NULL, 'Default Null Value', `field`) as `field` FROM `table` Would print the following: EDIT: I just realized for inserting data, not extracting it To insert with the if, check on PHP side
-
rewording the question does amazing things in google.
-
But then how do you know who the user is? Even so if you had the username I could edit my cookies to have your username and "yes"
-
Also, above that put error_reporting(E_ALL);
-
If it's a lot you are trying to pass to another script, look into the curl library and use a POST to the other script.
-
Make sure to use full tags (<?php ) instead of short tags (<? <?= ) Make sure to have session_start(); at the very tip top of your script
-
Haha, good choice! I didn't even notice that
-
I think his son would be smarter than you, sorry bud. Anyways, we're here to help not to just give away answers. Like Night said, what do you think the answer is, and why?
-
Why don't you just post the whole exam?
-
Instead of using defined variables somewhere else in the script, probably from another query, why not just do something like: $money = (int) $_POST['money']; // Set for int, not really needed with prepared statements but good habits $query = $db->execute("update `gangs` set `money`= `money` + ? where `id`=?", array($money, $player->gang_id)); $query1 = $db->execute("update `players` set `money`= `money` - ? where `id`=?", array($money, $player->id));
-
#34 ( Habitat 67 ) just looks like a pain in the ass to get from room to room
-
The variable that holds the class data is the object. Again: $ford = new car; $ford is the object, and car is the class. In other words: $theObject = new theClass
-
To add onto what Dennis said, it's called a ternary operation. http://us3.php.net/ternary#language.operators.comparison.ternary And isset checks to see if the variable has been set (is set)
-
HI - I THINK YOUR CAPS IS A BIT STICKY, BUT APPARENTLY SO IS MINE We have no idea what that function looks like without the code for the function
-
Its just how you think it would be //... while ($value = mysql_fetch_array($results)) { $aboutMe = wordwrap($value['about_me'], 64, '<br>'); //...