-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
'Are you sure you want to delete this record' page, any suggestions?
mikesta707 replied to bossman's topic in PHP Coding Help
yeah you would simply use on click and have it return true of false -
are you sure your img path is right. Try echoing what the img src would be and see if it is correct
-
[SOLVED] not sure how to make this less complicated
mikesta707 replied to M.O.S. Studios's topic in PHP Coding Help
The cool thing about classes is data encapsulation, so if you make a class var, named, say, $name, that var is accessible in every member function of the class. so for example class foo { private $word="Hello World!"; function bar(){ echo $this->word; } } $foo = new foo(); $foo->bar(); //output Hello World! This does a few things. Namely, it allows you to access variables in functions without having to pass them. so lets take one of your functions, and see how it would be in a class class foo{ private $item, $links, $name, $global, $catnum; //lets assume these are set before we call the function function replacesym($itemnum=NULL) { $item = str_replace("[#]",$this->global,$this->item); $item = str_replace("[cat#]",$this->catnum,$this->item); $item = str_replace("[item#]",$itemnum,$this->item); $item = str_replace("[url]",$this->links,$this->item); $item = str_replace("[name]",$this->name,$this->item); $item = str_replace("[nl]","\n",$this->item); // return $item; we could do this, or we could set the class variable like so $this->item =$item; } } Since the data is already set, and is already inside the class, that function only really needs one parameter, as opposed to 4-6 which could make it kind of clunky. This explanation is very basic though, and there is a lot more to classes than just this. Hope this helps -
this is just a guess, but you probably want this to be <?php echo $lastpicid .".". $ext; ?> otherwise, the source of the image would look like "mypicjpg" (assuming that $lastpicid is the name of the file, and $ext is the file extension
-
[SOLVED] not sure how to make this less complicated
mikesta707 replied to M.O.S. Studios's topic in PHP Coding Help
you COULD make this a class if you wanted to, and would probably be a good idea, but does the script as it stands work? it doesn't seem too complicated to me -
'Are you sure you want to delete this record' page, any suggestions?
mikesta707 replied to bossman's topic in PHP Coding Help
Be aware that javascript can be disabled by the client. This may not matter to you much, but you may want to take some extra precautions to make sure data doesn't get deleted accidently -
echo "<script type='text/javascript'> price['92342258697'] = '".$myvar."';\n </script>"; oh beaten to the punch. oh well
-
missing the $ array_push($svcIDs, "$staSvcIds") [/php[
-
[SOLVED] how to check if a variable is in an array
mikesta707 replied to a L p's topic in PHP Coding Help
yep, its called in_array if (in_array($needle, $haystack)){ //do something } with needle being your variable and haystack being your array -
so you DON'T want to use the alert function? Well you can use the window.open function to load a custom error box, but besides that I'm not sure
-
based on the following with(window.document.choices) shouldn't the name of your forms be "choices" They currently are not
-
many problems. mainly that you have to escape your single quotes if your entire string is encased in them if ($stuff['type'] == 'Administrator'){ echo '<a href="password_protected.php">Add/Edit/Delete RSS Feeds</a><br/><br/>'; echo '<a href="admin.php">Main Site Admin</a><br/><br/>'; echo '<SCRIPT type=\'text/javascript\' language=\'JavaScript\' src=\'http://xslt.alexa.com/site_stats/js/s/a?url=www.ssa.co.uk\'></SCRIPT>'; echo '<SCRIPT type=\'text/javascript\' language=\'JavaScript\' src=\'http://xslt.alexa.com/site_stats/js/t/a?url=www.ssa.co.uk\'></SCRIPT>'; } conversely, instead of escaping them "\'" you could just use double quotes
-
elseif ($directory == 'index') { needs to be index.php if ($directory == '/') { doesn't mean anything and will never actually run true. You are only seeing this line because it is also echoed in the else clause. I would set it up like this: <?php $page = array(); $page = explode("/", $PHP_SELF); $directory_no = count($page) - 1; $directory = $page[$directory_no]; if ($directory == 'index.php') { echo 'Plague Infected | Index'; } elseif ($directory == 'contact.php') { echo 'Plague Infected | Contact'; } elseif ($directory == 'portfolio.php') { echo 'Plague Infected | Portfolio'; } else { echo 'Plague Infected Designs | Freelance art and web design and development in Fort Worth TX and Puerto Rico'; } ?>
-
ok thats good. you can get rid of the echos and stuff. Just change your if statements accordingly, like for that page it should be if ($directory == "head.php"){ echo "whatever"; }
-
oh didn't notice something in your code above when I said print_r I meant print_r($page); not to do $page = print_r("/", $PHP_SELF); that is messing up your variables. change it back to $page = explode("/", $PHP_SELF); or whatever it was before
-
if ($_SERVER['PHP_SELF'] == "/index.php"){ //load the correct banner } Will get kind of clunky with more and more pages, but I would suggest putting the info in a database, or storing the relevant data into an array and getting it that way, like //database way $get = $_SERVER['PHP_SELF']; $sql = "SELECT src FROM bannerTable WHERE page='$get'"; $go = mysql_query($sql); $row = mysql_fetch_array($go); echo "<img src='".$row['src']"' id='banner' />";
-
oh dude my bad. I'm an idiot $page = array(); $page = print_r("/", $_SERVER['SCRIPT_NAME']); $directory_no = count($page) - 1; $directory = $page[$directory_no]; subtracted from the wrong variable. try that, with the echos and see what happens
-
this is not going to work. $_PHPSELF returns the page your are currently on, sans any paths to the document itself. So if i'm on www.facebook.com/books/awesome.php and I echo $_SERVER['PHP_SELF'] it will echo "/awesome.php" You are trying to test the variable against a full URL and it will never ever match those. none of those will work. And Echo the variable itself. As in change your code to $page = array(); $page = print_r("/", $_SERVER['SCRIPT_NAME']); $directory_no = count($page); $directory = $page[$directory_no] -1; print_r($page); echo $directory; if ($directory == 'http://plagueinfected.com/') { echo 'Plague Infected Designs | Freelance art and web design and development in Fort Worth TX and Puerto Rico'; } elseif ($directory == 'http://plagueinfected.com/?pg=index') { echo 'Plague Infected | Index'; } elseif ($directory == 'http://plagueinfected.com/contact.php') { echo 'Plague Infected | Contact'; } elseif ($directory == 'http://plagueinfected.com/portfolio.php') { echo 'Plague Infected | Portfolio'; } else { echo 'Plague Infected Designs | Freelance art and web design and development in Fort Worth TX and Puerto Rico'; } that will tell you what the actual variable itself looks like, and what you should change your test too
-
And it doesn't work for any of the pages? When you echoed them what did they say? oh and the URL won't look like this : /?pg=index index.php in that case. But the others should be fine. try also doing a print_r on $page and see what it holds
-
wait so when you echo the variable it just shows "-1" at the end of the word? what does your code look like now
-
echo the directory variable (both your constant and the variable itself) and see what happens. Perhaps the variable isn't the value you expect it to be
-
populating checkbox from database information
mikesta707 replied to bossman's topic in PHP Coding Help
This is a really round about way of doing this. Why not just have 1 column for the project name and enter like acro_9_prof and whatever else as values in each row? Do projects have multiple of those values checked at a time, or is it usually just 1 project checked? You are getting undefined variable errors because you only define the variable if a certain condition is met. if its not, then the variable won't be set. change your if statements to have an else clause like if ($acro_8_prof == "1") { $p1 = true; } else { $p1=false; } and then when you check it if ($p1) { Hope that helps -
$page = array(); $page = explode("/", $_SERVER['PHP_SELF']); $directory_no = count($page) -1; $directory = $page[$directory_no]; this line: $directory_no = count($page) - 2; should be -1, because you want to get the last entry in your exploded array (which would be the page itself) -2 will give you the second to last, and in many cases, that is also the first, and sometimes it will become -1. Hope that helps
-
But daniel... secret questions love you
-
When I did this, I stored the question in my database also, and stored the answer as an MD5 hash. As gareth said its pretty much just a simple query to get the information you want. not too hard