-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
How to View and Open Linux hard disk Files in Window?
JonnoTheDev replied to thamraj's topic in Linux
That is not an error. That is a solution -
use a php header to set the content type header('Content-type: text/html; charset=utf-8');
-
How do I pass a variable out of a function into main script?
JonnoTheDev replied to patrickcurl's topic in PHP Coding Help
agreed but you still see them -
How to View and Open Linux hard disk Files in Window?
JonnoTheDev replied to thamraj's topic in Linux
http://www.fs-driver.org/troubleshoot.html -
[SOLVED] call_user_func_array() and FrnotController class help
JonnoTheDev replied to keeps21's topic in PHP Coding Help
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); -
post to PHP on local machine without a server?
JonnoTheDev replied to allasso's topic in PHP Coding Help
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. -
sending 2 php forms with one click
JonnoTheDev replied to allybally85's topic in Third Party Scripts
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']; -
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
-
sending 2 php forms with one click
JonnoTheDev replied to allybally85's topic in Third Party Scripts
You dont need to submit twice just add an email function after the database insert -
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; } }
-
How do I pass a variable out of a function into main script?
JonnoTheDev replied to patrickcurl's topic in PHP Coding Help
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' -
How do I pass a variable out of a function into main script?
JonnoTheDev replied to patrickcurl's topic in PHP Coding Help
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! -
How do I pass a variable out of a function into main script?
JonnoTheDev replied to patrickcurl's topic in PHP Coding Help
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); ?> -
How do I pass a variable out of a function into main script?
JonnoTheDev replied to patrickcurl's topic in PHP Coding Help
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. -
How do I pass a variable out of a function into main script?
JonnoTheDev replied to patrickcurl's topic in PHP Coding Help
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; ?> -
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.
-
It's the easiest
-
Using a Case to store variables... Is there a smarter way
JonnoTheDev replied to blesseld's topic in PHP Coding Help
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']; ?> -
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, '/');
-
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'); ?>
-
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.
-
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.
-
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); ?>
-
[SOLVED] Virtual hosts. really need some help.
JonnoTheDev replied to lynxus's topic in Apache HTTP Server
http://forums.theplanet.com/index.php?showtopic=79287 -
[SOLVED] Virtual hosts. really need some help.
JonnoTheDev replied to lynxus's topic in Apache HTTP Server
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.