wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Could you post the code you use to perform your SQL Query here, aloing with the actuall query too. Not sure why you are getting that error. If you post your code, should be able to shed some light onto it.
-
[quote author=ToonMariner link=topic=108069.msg436541#msg436541 date=1158590504] Or use css... table { margin: 0 auto; } [/quote] That will fail in some browsers as you need to specify a width first, before the auto margins get calculated.
-
If you want to get image/file from another directory you'll either want to use a relative path or an absolute path [b]Relative path:[/b] [code=php:0]<img src="../other_dir_name/<?php echo $row_Recordset6['Name']; ?>">[/code] The ../ goes up one level from the current working direcotry (where the script is running) and then goes into the other_dir_name directory [b]Absolute path:[/b] [code=php:0]<?php $fullPath = 'http://' . $_SERVER['HOST_NAME' . '/other_dir_name/' . $row_Recordset6['Name']; echo '<img src="http://' . $fullPath . '">'; ?>[/code] Absolute path is where you provide the full path to the file/folder.
-
You'll want to warp your table inside a block level element if you want to center your table: [code]<div style="text-align: center"> <table border="1" cellpadding="2" cellspacing="1"> <tr> <td>Hello world</td> </tr> </table> </div>[/code]
-
Looks like your host has doesn't allow POST requests. You might want to talk to your host about this. Your code is fine. It is a server configuration issue on your hosts part.
-
Does die automatically terminate mySQL connections?
wildteen88 replied to manmanman's topic in PHP Coding Help
If you use a non persistent connection to the MySQL database, you dont need to add mysql_close() before die or exit. mysql_connect() <-- non persitant connection mysql_pconnect() <-- persistant connection If you use a persistant connection then you will need to add mysql_close() [b]before[/b] die or exit to close your persistant connection. -
can't access mysql with php setup
wildteen88 replied to jagguy's topic in PHP Installation and Configuration
Try this instead: [code=php:0]$conn = mysql_connect($dbhost, 'root', '');[/code] You need to define the username you want to use to connect to the MySQL server. the third paramter is where you enter the password in for the username you use. -
[quote author=redarrow link=topic=108394.msg436046#msg436046 date=1158505296] [code] <?php session_start(); $name="redarrow"; $name=$_SESSION['name']=$name; echo"<a href='test_result.php'>please see my name</a>"; ?> [/code] [/quote] Why on earth would do [code=php:0]$name=$_SESSION['name']=$name[/code] for? I see no logic in that.
-
Why dont you just mod_rewrite the query string. After all that is why mod_rewrite partly exists.
-
This bit makes not sense: [code]if(!htmlspecialchars($string)){ $string = htmlspecialchars($string); }[/code] How will PHP know you have ran htmlspecialchars? Also this bit of code [code=php:0]$string = htmlspecialchars($string);[/code] will never be run, as PHP will run htmlspecialchars on the string being passed to the function in this bit of code: [code=php:0]if(!htmlspecialchars($string)){[/code]. So yout function is abit of a waste.
-
Does PHP allow you to put 2 variables in a session?
wildteen88 replied to Drezard's topic in PHP Coding Help
Prehaps Drezard mean two values in one SESSION variable rather than having two session variables. So prehaps Drezard wants something like this: [code=php:0]session_start(); $username = 'someuser'; $password = 'somepass'; // NOw we create 1 session var to store the username and password: $_SESSION['userinfo']['username'] = $username; $_SESSION['userinfo']['password'] = $password;[/code] The above code creates 1 session variable ($_SESSION['userinfo'] which is an array) and holds two values the username and password. To retieve the username and password use this: $_SESSION['userinfo']['username'] - to grab the username $_SESSION['userinfo']['password'] - to grab the password Is that what you want? -
Did you make backups of your phpBB database from your other host, before you moved to your new host? If you did then you need to restore the database with your Backup you made. Therer is no point in recreated the tables as your phpBB forum will fail to work still. If you ahve not backup of the database then you need to make a fresh install of your phpBB forum.
-
Yeah we need more information. There are tons of different reasons why you get a so called [i]connection problem[/i]. Please post the full error(s) here. Aswell the code relating the the error(s).
-
Yes you need to install Apache to run your PHP scripts on your PC locally. MySQL doesn't need Apache. MySQL is database server. Apache is a web server. Installing Apache is rather easy. Make sure you download the msi package and download Apache2.0.x (don't download Apache2.2.x). When you run the Apache installer it'll ask you for a couple of details which are Network Domain ,Server Name and Administrator's Email Address For the Network Domain and Server Name just enter localhost into the two boxes. Then just add a false email addy into the Admins Email Address eg (admin@localhost). When it ask you where to install Apache to, install it in the root of your hard drive in a folder called server, so click the browse button when it asks for installation directory, type in C:\server, the server folder will be created if it doesn't exists, also change C: to the letter of your hard drive. Now go through the rest of the installation process. Once Apache is installed, fire up a web browser and type in http://localhost or http://127.0.0.1 The above addresses are local addresses, that only you can access. No one from the web/out side of your network can access those addresses. You should get the Apache welcome message when you go to either of the above addresses. Now to install PHP, you'll need to go to php.net and download PHP5. Make sure you download the zipped binaries and NOT the INSTALLER. Once you have downloaded PHP. Extract the contents of the zip file to C:\server\PHP\ Once you have extracted the contents of the ZIP. PHP is installed! However you must now configure Apache to parse any PHP files with the PHP Interpreter. To do so go to C:\server\Apache2\conf and open up httpd.conf for editing. Now look for the following: [code]#LoadModule ssl_module modules/mod_ssl.so[/code] Add the following after the above: [code]LoadModule php5_module "C:/server/php/php5apache2.dll" #PHPIniDir PHPIniDir "C:/WINDOWS"[/code] Now scroll down further to find the following: [code]AddType application/x-gzip .gz .tgz[/code] Now add the following after the above: [code]AddType application/x-httpd-php .php[/code] Save the httpd.conf file! What you need to do now is go to C:\server\php and find the following files: libmysql.dll php5ts.dll php.ini-recommended Copy the above three files to the WINDOWS folder (C:WINDOWS\). Once you have done so. Rename php.ini-recommended to just php.ini Now you have setup Apache to parse the PHP files with the PHP Interpreter. All you need to do now is restart Apache. To do so go to Start > Program Files > Apache HTTP Server 2.0.x > Control Apache Server > Restart If everything goes to plan. Apache should restart without any beeps/errors popping up. If no beeps/errors come up then Apache and PHP are installed. To test go to C:\server\Apache2\htdocs\ create a new file called test.php, edit this new file and add the following code to it: [code=php:0]<?php phpinfo(); ?>[/code] Save test.php. Now open up your browser again and go to http://localhost/test.php When you go to that address you should get a page full of information about PHP and your server. If you do then Apache and PHP are successfully installed. All you need to do now is install MySQL, which is easy as its just a step through installer. Make sure when you go to install MySQL you install it in the server folder (NOTE: You'll need to choose the custom install option to do this). When MySQL is installed you'll need to enable the MySQL extension for PHP to use in order for you to use PHP with MySQL. You can do this by reading [url=http://www.phpfreaks.com/forums/index.php/topic,95378.0.html]this thread[/url]. Hope that helps.
-
What gap are we talking about? Do you mean the blue bit? Or do you emam the gap between the address bar of the browser and your menu? Rather than adding zero margins to the top of body, ad zero margins and padding to the whole of the body, so instead of: [code]body { background-image: url(images/Net_U_bg.png); background-repeat: repeat-x; margin: 0px; padding: 0px; }[/code] IE7 displays the layout fine!
-
Use unset or redifine $blablah to have a null value [code=php:0]// unset deletes the variabl $blahBlah unset($blablah); // or redifine blabla with a null value, so its not an array anymore $blablah = '';[/code] Or do what ken says above, redifine blabla as an empty array.
-
is this speed sutibal for a http server
wildteen88 replied to lm_a_dope's topic in Apache HTTP Server
Where is the server located to, and is the server hosted by you? If its hosted by you then you'll want to have a good upload speed, the better your upload speed is the better the ping will be. Remeber what ever you upload speed is will be the maximun someone can download from you. So if you have a max upload speed is of 50KBytes a secound the maximun someone can download from you will be 50KB(ytes) per secound. No matter what the other persons download speed is. -
Use this: [code=php:0]// chekc that page is srt and that it holds a numerical value if(isset($_GET['page']) && is_numeric($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; }[/code] If your url is index.php?page= or index.php?page=' or someothing else that is non numeric it will set $page to 1. if your url is this: index.php?page=1 or index.php?page=somenumberhere (eg index.php?page=99) it'll set $page to $_GET['page'] This is more secure than what you have now.
-
This portion of the code is wrong: [code]$query4 = mysql_query($calsql4, $link); $result = mysql_query($query4) or die('Query failed: ' . mysql_error());[/code] You've already ran the query ($calsql4) and stored the results of the query in $query4. Then you are running $query4 through mysql_query, which $query4 is not query. $query4 holds the results and thus you get the [i]Query failed: Query was empty[/i] message. So instead use this code to run the query: [code=php:0]$result = mysql_query($calsql4, $link) or die('Query failed: ' . mysql_error());[/code]
-
Use a foreach loop to loop through all variables in the url: [code=php:0]$url = array(); foreach($_GET as $key => $value) { $url[$key] = $value; }[/code] However the following is the same as above: [code=php:0]$url = $_GET;[/code] The $_GET variable is what gets the variables from the url. if you wnat to just get the variable names from thr URL use this: [code=php:0]$url = array(); foreach($_GET as $key => $value) { $url[] = $key; } echo "<pre>\n" . print_r($url, true) . '</pre>';[/code]
-
Thread close. Please do not post multiple instances of threads around the forum.
-
Could you explain what this code is supposed to and what your aim is. As looking at your code you have implemented pagination to pagenate your results. However you use $page ($_GET['page']) to do something else. Which is where I'm getting confused. Do you want to use $_GET['page'] to fetch more information based on the Name you click?
-
[quote]By ID number i mean the id number of the actual row, not the row number.[/quote] Then your original code should be fine: [code=php:0]echo ('<a href="1.php?page=' . $row['id'] . ' ">' . $row['name'] . ' </a><br />');[/code] $row['id'] holds the id number of the row in the database, thats is asociated with the name ($row['name']). I'm a little confused at what you are trying to do.
-
Course, you can use a ternitry operator. Eg: [code=php:0]$color = 'red'; $color = ($color == 'red') ? 'blue' : 'red';[/code] Or the longer version is: [code=php:0]if($color == 'red') { $color = 'blue'; } else { $color = 'red'; }[/code]
-
Not really no as PHP doesnt load the pages into memery. It just parses php code in the php files. Whne its done parsing the script it releases any memory being used back to the system, this is why variables/constants only work on the file they where created on. PHP only runs on a per-request basis, meaning it'll only run when a client (web browser) request the server for the desiered PHP file.