wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Make sure you provide the link resource whenever you call a mysql function which requires it. eg: $conn1 = mysql_connect('server1', 'userr1', 'pass1); # server1 $conn2 = mysql_connect('server2', 'userr2', 'pass2'); # server2 # select databases mysql_select_database('server1_db', $conn1); # server1 database mysql_select_database('server2_db', $conn2); # server2 database #query server $server1_qry = mysql_query('Select * from tbl_name', $conn1); # query server 1 database $server2_qry = mysql_query('Select * from tbl_name', $conn2); # query server 2 database #close connections mysql_close($conn1) # close server1 connection mysql_close($conn2) # close server2 connection Variables $conn1 and $conn2 contain the link resource, you'll notice these are passed as the second parameters to the above functions. This is how you deal with multiple connections to different servers/databases as the sametime. Note not all mysql functions require the link resource to be provided you should check the manual for which functions do.
-
Looking at your code I see one error, which is the following line: append_file('test.txt', '$result['id']<br>~<br>'); Variables do not get parsed when inside single quotes you should use double quotes, or better still use concatenation: # concatenation: append_file('test.txt', $result['id'] . '<br>~<br>'); # double qoutes: append_file('test.txt', "{$result['id']}<br>~<br>");
-
Have a read of the following tutorial, should help you.
-
Installation problems - php.ini
wildteen88 replied to kinda's topic in PHP Installation and Configuration
@sanjivus remove the trailing slash on the following line: PHPIniDir "C:\WAMP\PHP\" So the above line looks like: PHPIniDir "C:\WAMP\PHP" Save your httpd.conf and restart Apache. I find it best to leave of trailing slashes for directory paths. -
Need compiling help
wildteen88 replied to nightmares18's topic in PHP Installation and Configuration
Why are you wanting to re-compile PHP on Windows? PHP comes pre-compiled for Windows. -
If PHP is retrieving data from external sites using functions such as fopen/fread or file_get_contents then maybe a setting called allow_url_fopen is disabled and thus your third party PHP scripts you are using are failing to function. Try enabling display_errors and set error_reporting to E_ALL within the php.ini for your IIS setup. PHP is cross platform compatible, there is no difference between PHP on Windows or Linux. The only thing that can cause trouble is PHP's configuration.
-
The change is to do with the mysqli extensions your are using not your code. You are getting confused with mysql_error function from the standard mysql extension. which can accept an optional link resource parameter. With the release of the mysqli extension the mysqli_error function now requires the link resource. Try passing the $conn variable as the parameter when calling mysqli_error. $query = "insert into customers(name,address,city,state,zip,country) values($name','$address','$city','$state','$zip','$country')"; $result = $conn->query($query)or die(mysqli_error($conn));
-
Change line 64 to: $r = mysql_query($q) or die('Query error: ' . mysql_error() . '<pre>' . $q . '</pre>'); There is most probably a problem with your query.
-
In order for any errors to be shown when the code is being executed, make sure error_reporting is set to E_ALL and that display_errors is enabled within the php.ini. Also I would recommend you to change the following two lines: $connection = mysql_connect("localhost", "user", "pwd"); mysql_select_db("db", $connection); to: $connection = mysql_connect("localhost", "user", "pwd") or die('MySQL Connection Failed! - ' . mysql_error()); mysql_select_db("db", $connection) or die(mysql_error()); and change the following line: $resDist = mysql_query($sqlDist, $connection); to: $resDist = mysql_query($sqlDist, $connection) or die('Query Error: ' . mysql_error() . '<br /><pre>' . $sqlDist . '</pre>');
-
Problems with Installing
wildteen88 replied to Saint2054's topic in PHP Installation and Configuration
By that do you mean you have your PHP code within an HTML file (.html). If so then no it wont work. You should save your PHP code within a .php file in order for the PHP code to execute. HTML code can go inside .php files, eg: <html> <head> <title>PHPInfo</title> </head> <body> <?php phpinfo (); ?> </body> </html> If you want to parse .html files as PHP you can do so by appending .html to the following line within the httpd.conf: AddType application/x-httpd-php .php Example: AddType application/x-httpd-php .php .html -
.htaccess protection on all files but one
wildteen88 replied to cgm225's topic in Apache HTTP Server
You'll want to use the following configuration for the .htaccess file: Deny from all # deny access to includes/php # allow access to includes/php/galleryFileCalledByJavaApp.php only. <Files "galleryFileCalledByJavaApp.php"> Allow from all </Files> -
What do you mean by ip address of the machine? What address are you using to access the webserver? Are you accessing it locally (LAN/computer) or remotely (internet). Need more information not quite understanding you.
-
Umm, that function will return the disk/partition size the directory is located on. It doesn't calculate the size of the directory. Looking through my old scripts I found this: <?php /* Disclamper: The following function was taken from http://uk3.php.net/manual/en/function.disk-total-space.php#75971 */ function getSymbolByQuantity($bytes) { $symbols = array('Bytes', 'KB', 'MB', 'GB'); $exp = floor(log($bytes)/log(1024)); return sprintf('%.2f '.$symbols[$exp], ($bytes/pow(1024, floor($exp)))); } /* End Disclaimer */ function folder_size($path='.', $dirSize=0) { if(!is_dir($path)) die('Path (' . $path . ') is invalid'); $handle = opendir($path); $ignoreFiles = array('.', '..'); while ( false !== ($file = readdir($handle))) { if (!in_array($file, $ignoreFiles)) { $filePath = $path . '/' . $file; if(is_dir($filePath)) { $dirSize = folder_size($filePath, $dirSize); } else { $dirSize += filesize($filePath); } } } closedir($handle); return $dirSize; } $folder_size = getSymbolByQuantity(folder_size('.')); echo 'Total folder size = ' . $folder_size; ?> Note: getSymbolByQuantity function is not mine.
-
APACHE SERVER & PHP INSTALLATION
wildteen88 replied to KTTHOOL's topic in PHP Installation and Configuration
Open your httpd.conf file (Start > All programs > Apache > Configure Apache Server > Edit the Apache httpd.conf Configuration File) Search for the following line: # If your host doesn't have a registered DNS name, enter its IP address here. After that line should be: ServerName After ServerName just type in localhost:80, eg: ServerName localhost:80 . Save httpd.conf and restart Apache. Apache should not be reporting the above error upon starting. -
passing variables between forms
wildteen88 replied to burnthand's topic in PHP Installation and Configuration
It is because you're using short tags (<? ?> or <?= ?>). I'd would highly recommend you change your script to use the full PHP tags (<?php ?> or <?php echo ?>). Using full PHP tags will allow your code to be more portable/compatible with other PHP setups. -
All errors are caused by the first error. Looking at the first error it is a file permission issue in /home/vpgmcom/tmp/ make sure that the tmp folder has the correct permissions for PHP to save session files to that location.
-
For suggestions of PHP editors to use please look in this thread. As the problem has been solved and to prevent this thread going off topic I will lock it
-
Ummm, the solution has been posted above by darkfreaks and Daniel0
-
Like so: echo 'string with \' in'; or echo "string with ' in"; Both will return the same result, except the first one uses \' to output an apostrophe within a string. This is because it is escaped using the escape character (\). The reason for this is because the string is defined within single quotes, if you don't escape quotes within your string PHP will think you're ending the string and thus you'll most likely get an error. The same applies to strings defined with double quotes too.
-
No because the displayname and the firstname/lastname are stored in separate fields within the users table. What the OP wants to do is return the firstname and lastname as the displayname if the displayname is not set within the users table, or just the displayname if it is set. My query does this.
-
Problems with Installing
wildteen88 replied to Saint2054's topic in PHP Installation and Configuration
Seems strange. PHP is loaded as an Apache as. Enable the following settings within the php: display_errors (and ensure error_reporting is set to E_ALL) display_startup_errors Save the php.ini and restart Apache. Is there any errors reported during startup, or when running your script. Also note you don't need to set the doc_root within your php.ini. -
About using raw user input (from $_POST/$_GET etc) in a query? If so have a read up on SQL Injection. If you use your script as it is it'll be prone to SQL Injections which will allow a malicious user to perform SQL queries from your form.
-
Login Problems.. and no error? Please help :)
wildteen88 replied to jadedknight's topic in PHP Coding Help
Shouldn't this line (line 40): if (_check_login($username, $password)) be if ($this->_check_login($username, $password)) -
Problem with htacces in apache and windows server
wildteen88 replied to b2k's topic in Apache HTTP Server
What url are you using when you get the forbidden error? I don't think its an issue with the htaccess file I think its to do with how you're accessing a file.