-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
How to use variable as global variable ?
PFMaBiSmAd replied to arif_shariati's topic in PHP Coding Help
Perhaps if you posted your code that demonstrates the problem. However, just wrapping function definitions around pieces of your main application code does not necessarily result in well designed and usable functions and if you have data and code that is related and is always used together, you should be using a class instead of functions. -
Perhaps if you provided - a 'diagram/list' showing what different servers are involved; identify which server you have referred to as 'main' and 'remote'; where the fire wall is at and exactly what data it does not not permit that is relevant to this problem; which server has the database; which server does the client/browser connect to; WHY you don't have all the application code on the server where the database is at; someone could probably help you.
-
This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=319108.0
-
How to use variable as global variable ?
PFMaBiSmAd replied to arif_shariati's topic in PHP Coding Help
The global keyword does not make a variable global between pages and in fact forget that ever saw the global keyword as using it where it does do something, results in bad programming. To allow a php variables to exist between pages, you would use $_SESSION variables. See this introduction link - http://us.php.net/manual/en/features.sessions.php and the session reference link on that page - http://us.php.net/manual/en/book.session.php Setting a session variable on a page - <?php session_start(); // start or resume a session $_SESSION['some_name'] = 'your data'; ?> Referencing a session variable on a different page - <?php session_start(); // start or resume a session echo $_SESSION['some_name']; ?> -
If your mysql_query() statement attempted to created a database connection, it means that your actual connection code either was not executed or failed to make a connection. Either your include() statement failed because the path or the file name is wrong, your code in photoconnect.php was not seen as being php code (using short open tags <? or has not php tags at all), or the mysql_connect() statement in photoconnect.php failed (do you have any error checking logic in your photoconnect.php code to even test if the connection worked?)
-
session_is_registered() was depreciated over 8 years ago when the $_SESSION variable was introduced. You would use isset() to test if a $_SESSION variable is set or not.
-
For a feature like you are asking, you need a more sophisticated login system than just having a session variable that says a visitor is logged in. Because if someone is abusing your site, they can get a new session on every message they post and your admin function would not necessarily be using the latest session id and if all you are doing is destroying a session to log someone out, an automated script can get a new session and log in a lot faster than you can keep up with it. You need a login system that checks your user table on each http request to get the current logged in/out/banned status for the user. This will do two things, make your admin code very simple and make the system fool proof. If you set the status to 'banned' in your user table, on the next http request it will take affect and stop the abusive posting.
-
^^^ Your code is only fetching one row from the result set but is looping over that same row in a forever loop, concatenating it to itself over and over until all available memory has been consumed.
-
String data needs to be enclosed in single-quotes to make it string data, otherwise it is treated as an identifier (database, table, or column name.)
-
The most apparent problem in your full code that does not work is that you are putting the email address that was entered into the From: header. You need to put an email address hosted at the sending mail server into the From: header and you can put any entered email address into the Reply-to: header. To find if there are any php errors returned by the mail() function call, set error_reporting to E_ALL (or a -1) and display_errors to ON - ini_set("display_errors", "1"); error_reporting(-1);
-
Care to tell someone what error that was so they know where to start looking at?
-
You need to echo the query so that you can see what it actually is, but the error is typical of the $time variable not having a value when the query was executed.
-
Then you have been producing invalid html for a while too. Just because something works, does not mean it is correct. See this link to validate your html output - http://validator.w3.org/
-
Your HTML is invalid. You need quotes around each attribute value - echo "<input type='checkbox' name='b[$a]' value='1'>view,";
-
Using a URL in an include() statement causes a HTTP request to be made to the target file (the same as if you browsed to the file) and since php code is parsed and executed ON the server where the target file is located, you only receive and include any output that is sent from that file, not the php code.
-
You would need to show us what result you are seeing in front of you for anyone to be able to help with it. Best guess is some of your data values contain white-space/non-printing characters and the query does not match them.
-
Looping through foreach with xml data
PFMaBiSmAd replied to isimpledesign's topic in PHP Coding Help
It appears that your class returns the xml document in the $res variable. You should use an xml parser, such as simplexml to operate on the xml document as an object. You would then use something similar to the following - $xml = simplexml_load_string($res); // echo '<pre>',print_r($xml,true),'</pre>'; // examine the data echo "Request id: {$xml['request_id']}<br />"; // attribute echo "Code: {$xml->response['code']}, Text: {$xml->response['text']}<br /><br />"; // attributes foreach($xml->response->account as $node){ echo "Datatype: {$node['datatype']}<br />"; // attribute echo "Name: {$node->name}<br />"; // data echo "Type: {$node->type}<br />"; echo "Descr: {$node->descr}<br />"; echo "Server: {$node->server}<br /><br />"; } -
So, is your actual problem in producing the PDF document, serving the PDF document to the client/browser, or in printing the PDF document in the client/browser? Relevant code showing how the Active X comes into play would help.
-
A GET parameter on a URL looks like - file.php?some_name=value In php you would reference the value using $_GET['some_name'] For what you are doing, you would probably want to use picid as the name.
-
The 'code' you posted in reply #5 works after you remove the error producing strip_tags() from it (also, since $_POST['Pay'] is an array, using mysql_real_escape_string on it produces an error and returns nothing that the suggested php error_reporting/display_errors settings would help you find.) In your last tread, where you were trying to access sequentially numbered form fields, someone suggested displaying the $_POST array so that you can see what you are actually receiving. I recommend you do the same in this thread. You haven't exactly defined what you are trying to do (little or no real code), so it is not exactly possible to help you with it. What you posted in reply #5 produces an array $_POST['Pay'] that contains - Array ( [60] => Pay ) that has a key that you used in the form name and a value 'Pay'.
-
Remove the single-quotes that are around the sub-query.
-
$numbers= "$no1 $no2"; If these are already in the same database table where you want store the results, you can do this using a single UPDATE query. No php code is needed.
-
mysql_connect and php_network_getaddresses
PFMaBiSmAd replied to The Little Guy's topic in PHP Coding Help
It would probably be a good idea for you to read the documentation for mysql_connect(). The first parameter is the host name/ip of the mysql server.