Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. That is not an error. That is a solution
  2. use a php header to set the content type header('Content-type: text/html; charset=utf-8');
  3. http://www.fs-driver.org/troubleshoot.html
  4. It is passed in as the first parameter in whatever controller function is called Here is your controller object $dispatch = new $controller($this->controllerName,$action); This is the classname $controller This will pass the query string as a parameter into the controller method call_user_func_array(array($dispatch,$action),$queryString);
  5. NO! You would have to have the script installed on each individual mac if php is available also mysql and database if required. PHP is server side. It doesn't run like javascript does in a web browser.
  6. You send the email AFTER the form has been submitted, not within the form. If you don't and the user keeps refreshing the page you will get multiple emails. The keyword will be contained in $_POST['kw'];
  7. Are you saying that you want to see if the url is valid i.e. it returns a 200 OK header or are you just wanting to check that a string is in the format of a url? i.e. contains http://,https://, .tld
  8. You dont need to submit twice just add an email function after the database insert
  9. This is bad syntax public private var $eycolor = 'brown'; The var syntax is depriciated as of php5 and you can only use 1 type of access specifier i.e public $eyecolor; class parents { protected $name; protected $eyecolour; public function setcolour($colour) { $this->eyecolour = $colour; } }
  10. From looking at your code I can see bad database design which is why you are having to use so many queries. You are looking up a session_id record against 10 fields. For this you should have used a many to many relationship i.e. Instead of users ********* user_id name spid1 spid2 spid3 etc. Your db design should take the form of users ********* user_id name spid ********* spid_id name users_to_spid ************* uts_id user_id spid_id i.e If user_id 1 is related to spid_id 1,2,3 then your recordset would look like 1 1 1 2 1 2 3 1 3 Then you can achieve your report using 1 simple query. What spids is my user joined to? SELECT s.name AS spidName FROM spid s, users_to_spid uts WHERE s.spid_id=uts.spid_id AND uts.userId='1'
  11. I am unsure why you are even putting this into a function. Do you use this code in more than 1 section of your application. IMO functions are not used to print output. They are used to return data by using given input (parameters). The global scope of the application should output the data returned from a function. I think you need to read up on functions. Once the return syntax is used in a function it ends and the data is returned to the global scope!
  12. You need to return a value from the function and remove the global variable. Pass the value into the function instead $session_id <?php function downlow($spidz, $level, $stat_num, $session_id){ $result = mysql_query("SELECT twid FROM users WHERE $spidz = '${session_id}'") or die (mysql_error()); $up_num = mysql_num_rows($result); return $up_num; } $stat1 = downlow('spid1','Level 1',$stat_num,$session_id); ?>
  13. Well, honestly no there isn't really as there are better alternatives. If global variables in the function are used at all then they should be limited to 1 or 2 only and not a mass of variables. Things like database connection handles or file handles are sometimes seen as globals in functions from open source scripts that I have experience with.
  14. Simple answer. Dont use global variables! There is a time and place for them but not in your case. You should return a value from your function i.e. <?php function setVal($x) { $x = $x+1; return $x; } $value = 10; $newVal = setVal($value); // will print 11 print $newVal."<br />"; $newVal = setVal($newVal); // will print 12 print $newVal; ?>
  15. Yes, put the pointer back to the beginning of the array for your second loop. Do not run the same query twice as zer0day has suggested.
  16. It's the easiest
  17. If it is only you updating then it may aswell be in a static file unless you start to add many more pages then a database is the best bet. If static I think I would have used an array with the page id as the key: <?php $pages[1] = array('title' => 'home', 'meta_key' => '', 'meta_desc' => ''); $pages[2] = array('title' => 'about', 'meta_key' => '', 'meta_desc' => ''); $pages[3] = array('title' => 'contact us', 'meta_key' => '', 'meta_desc' => ''); // get page details - if page_id parameter is not set or invalid then set to 1 $thisPage = $pages[(array_key_exists($_GET['page_id'], $pages) ? $_GET['page_id'] : 1)]; print $thisPage['title']; ?>
  18. You need to set this constant in the config file DIR_FS_CATALOG It is the path to the document root i.e. /public_html/mywebsite/ define(DIR_FS_CATALOG, '/');
  19. This would be achieved in your htaccess using the following: php_flag display_errors off You do not have to set these things in an .htaccess file. You could use a common include file within the application i.e. config.inc.php <?php ini_set('display_errors', 'on'); ?>
  20. Clean and simple. Easy to navigate. Just a note that some of your pages like disclaimer, legal information, contact and location from the sitemap are automatically blocked by popup blockers. May want to look at your javascript or an alternate method to display the info.
  21. You don't. If you want to set an environment variable for your php script then you place it within the script. If you want to set a variable for the entire webserver then you should use the httpd.conf file and restart the server.
  22. Your parameters are in the format of a GET request not POST. Here is a function so you can use an array for post fields. The key is the field name & the value is the input value. The file index.php should be part of the url not the POST data. <?php function postString($dataArray) { foreach($dataArray as $key => $value) { if(strlen(trim($value)) > 0) { $value = is_array($value) ? $value : urlencode($value); $tempString[] = $key . "=" . $value; } else { $tempString[] = $key; } } $queryString = join('&', $tempString); return $queryString; } // url $target = "http://****.com/ipb/index.php"; // post data $postArray['UserName'] = "joe"; $postArray['PassWord'] = "bloggs"; $postArray['act'] = "Login"; curl_setopt($ch, CURLOPT_URL, $target); curl_setopt($ch, CURLOPT_POSTFIELDS, postString($postArray)); curl_setopt($ch, CURLOPT_POST, TRUE); ?>
  23. http://forums.theplanet.com/index.php?showtopic=79287
  24. This does not make sense. Please elaborate. Virtual hosting just allows multiple websites to use the same IP Address (A record) and are served from unique document roots.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.