-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
Sorry for not getting back quicker. Could not see any error from the code that you had posted. Glad you solved it.
-
html form data containing foreign languages; entering db
JonnoTheDev replied to Harry2o's topic in MySQL Help
Then your database must already be configured to use UTF8 as the default charset -
This really doesn't make sense. Are you posting the entire code? I can only see 1 query. I cannot see where $id is set. If you want to join more than one table you use the JOIN syntax in your query. You do not run sub queries! A while loop is a while loop regardless of the language, php, asp, c, etc There are also for loops, foreach loops, do while loops, however a while loop is fine. As for the second point, how else would you display data in a web browser? The HTML has to exist. The echo command prints the string of HTML containing your dynamic data from your database query. You need a loop if there is more than 1 record retuned from a query.
-
html form data containing foreign languages; entering db
JonnoTheDev replied to Harry2o's topic in MySQL Help
Yes, unless you have access to your my.conf file. You should really only connect to the database in one area i.e in a function or a common include, or a mysql db wrapper class i.e http://www.ricocheting.com/code/php/mysql-database-class-wrapper therefore it only takes one line throughout the whole application. Doesn't make a difference including the other php functions you are using. -
View the HTML source from the screen. Are you sure it is not there? Run the query in phpmyadmin or whatever you manage your database with to see what results are returned: SELECT * FROM ani_character WHERE anime_id=$id Simple tests, but a while loop will not exclude data.
-
If you are including a file twice via include() you will get that error. I wouldn't normally suggest this however, ammend your includes to include_once() or require_once(). It seems that you must have a poor application layout. A check you can perform when including class files: <?php if (!class_exists('FoobarClass')) { require_once('classes/foobar.class.php'); } $foobar = new FoobarClass(); ?>
-
html form data containing foreign languages; entering db
JonnoTheDev replied to Harry2o's topic in MySQL Help
After you connect to your database using mysql_connect() run the following query: <?php mysql_query('SET NAMES UTF8'); ?> At the top of your page add the following header: <?php header('Content-Type: text/html; charset=UTF-8'); ?> You should have no problems with those characters. -
This is silly. iFrames are from the far reaches of hell and died back in 1999. You should simply redirect all your domains to the main website via a 301. You can add a parameter onto the url that specifies the originating site and use that to change the header by storing in a session or whatever. However, if you want each domain without a redirect, and by just changing the title of the site for each, are asking Google to penalize you for duplicate content across multiple domains! The sites will end up in the sandbox for sure. What you should do is point the A records of each domain to the web server that hosts the site. Set these domains up the the Apache configuration and point them all at the main website's document root. Each domain will serve the same website, however you can now use the following to change the content of your site dependent on each domain: $_SERVER['HTTP_HOST'] So <?php /* you could put all this in a common include */ $sites['www.specialpizza.com'] = array('title' => 'Special Pizza', 'description' => 'Some text'); $sites['www.mainstreetspecialpizza.com'] = array('title' => 'Main Street Pizza'); $sites['www.elmstreetspecialpizza.com'] = array('title' => 'Elm Street Pizza'); $mysite_data = $sites[$_SERVER['HTTP_HOST']]; /* index file */ echo $mysite_data['title']; ?> Personally, I would forget what you are trying to do and simply redirect all your domains to the main website as suggested above. You should always redirect non www to a www address or vica versa. You should never have both.
-
LOL
-
As devices & operating systems are constantly being released the above method is not brilliant. Also some mobile providers use transcoded requests to websites so the user agent will not always be that of the phone. You may want to also control the content to certain devices, i.e a smartphone will get a javascript featured mobile version of your website with the ability to switch to the main website. A tablet will get a shrunk down version of your main website, and a feature phone will get a very basic text version. You can only achieve this by querying the device and you will need the WURFL database http://wurfl.sourceforge.net/ It is really simple to setup and the API code has plenty of examples. You should update the database about once a month for any new devices, browsers & operating systems that are released.
-
Fitting every image into a "standard size"
JonnoTheDev replied to Fenhopi's topic in PHP Coding Help
eh? Lets say that you want all the uploaded pictures to have a max height of 300px and a max width of 200px. Any images that users upload which are smaller than these dimensions are going to look stupid, however you can check the image size using the following function: http://uk3.php.net/get_image_size If the image is smaller than you require, you could send a message to the user and simply delete the image from the server. If the image is accepted then you need to use a graphics library to rescale/resize the image to the appropriate dimesions. Based on the orientation of the image it will either have a max height of 300px or a max width of 200px (landscape). Or, you may want a fixed size of 300x200 so therefore you will need to crop the image. You can use php's GD library to perform these operations http://uk3.php.net/manual/en/ref.image.php There are plenty of tutorials available. I would personally recommend installing Image Magic on your server as this is much more powerful. http://www.imagemagick.org/script/index.php Again there are loads of tutorials out there. -
Yep, sort of just staring into blank space at the moment with no idea of what I am doing.
-
Just come back from a weeks holiday in the sun to miserable weather, traffic jams and hundreds of emails. Depressing to say the least!
-
Next week's lottery numbers please!
-
How can anyone predict what is likely in the next 5 years.
-
I need some help formating dates and limiting words
JonnoTheDev replied to geko21's topic in PHP Coding Help
<?php $date = date('d-m-y', strtotime($row->date_post)); $date = implode('<br />', explode('-',$date)); echo $date; ?> Dates in a mysql table should be stored in DATE type and not as strings in a VARCHAR. A proper date format is YYYY-MM-DD. You can then convert to UK format using PHP. PHP's date & time functions can become confused when using UK date format. -
I need some help formating dates and limiting words
JonnoTheDev replied to geko21's topic in PHP Coding Help
1 <?php $date = '17/01/2011'; $date = implode('<br />', explode('/',$date)); echo $date; /* or */ $date = '17/01/2011'; $date = date('d<br />m<br />y', strtotime($date)); echo $date; ?> 2 <?php $sometext = 'Hello my name is Neil'; $chars = 16; $subtext = substr($sometext, 0, $chars); echo $subtext.'.....'; ?> These are really common and simple php functions. I would recommend a basic reference book to assist you with anything small like the above that you need to do. -
I haven't seen PCMCIA for years. Can you even get new laptops with PCMCIA support? Anyway, there are type 1 (16bit) & 2 (32bit) cards and they are not compatible. If you have laptops with Type 1 card slots they must be really old (talking Windows 95 old)
-
That's an awful method you are using. You can add this to your class. The function param is an array of the elements that you wish to remove: <?php function query_remove($string, array $elements) { $parts = explode('&', $string); $new_query = array(); foreach($parts as $param_val) { $param_val_parts = explode('=', $param_val); if(!in_array($param_val_parts[0], $elements)) { $new_query[] = $param_val; } } return implode('&', $new_query); } $string = 'elementA=valueA&elementB=valueB&elementC=valueC'; echo "<p>".query_remove($string, array('elementA','elementC'))."</p>"; echo "<p>".query_remove($string, array('elementB','elementC'))."</p>"; echo "<p>".query_remove($string, array('elementA'))."</p>"; ?>
-
There are other ways however this is by far the simplest
-
To make this simple, what you need to do have the select options on a form prior to the form that submits to paypal. i.e start.php -> end.php Here's a really basic example using an array of products: start.php <?php $products = array('1 month registration' => '10.99','2 months registration' => '15.99','3 months registration' => '25.99'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Select your amount</title> </head> <body> <p>Please select the product you require:</p> <form method="post" action="end.php"> <?php foreach($products as $name => $price): ?> <input type="radio" name="product" value="<?php echo $price; ?>" /> <?php echo $name; ?> $<?php echo $price; ?><br /> <?php endforeach; ?> <input type="submit" /> </form> </body> </html> end.php <?php $products = array('1 month registration' => '10.99','2 months registration' => '15.99','3 months registration' => '25.99'); if($_POST) { if(!empty($_POST['product'])) { $price = $_POST['product']; } else { /* redirect user back to options if they have not selected a product */ header('Location:/start.php'); exit(); } } else { header('Location:/start.php'); exit(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Continue</title> </head> <body> <p>You have chosen to buy <?php echo array_search($_POST['product'],$products); ?> @ $<?php echo $price; ?></p> <form action="https://www.paypal.com" method="post"> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="business" value="test@test.com" /> <input type="hidden" name="lc" value="US" /> <input type="hidden" name="item_name" value="Registration" /> <input type="hidden" name="item_number" value="1011010102" /> <input type="hidden" name="amount" value="<?php echo $price; ?>" /> <input type="hidden" name="currency_code" value="USD" /> <input type="hidden" name="button_subtype" value="services" /> <input type="hidden" name="no_note" value="0" /> <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest" /> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" /> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1" /> </form> </body> </html>
-
You should be careful what you post here! If you have tried to code this, which none of your posts suggest you have, apart from failing to find anything using Google, then why are you not asking for help with the script you have put together? Post the code that you have created and people here will assist you with it or at least point you in the right direction. Although, if you are so quick to offend then you may struggle to get any!
-
Check box to go to next step ..help..
JonnoTheDev replied to Chrisislost86's topic in PHP Coding Help
Look at my code again. It is clearly commented. Fit your logic into the appropriate bits. I strongly suggest a book if you are a complete novice. Without actually writing the whole thing for you, there is not much more to put in a response. This is so simple. -
Check box to go to next step ..help..
JonnoTheDev replied to Chrisislost86's topic in PHP Coding Help
Give the checkbox a more appropriate value and then test for it. Also check your HTML, there is no method attribute in a checkbox element. <?php if($_POST) { /* is the checkbox checked? */ if($_POST['personal'] == 'checked') { /* yes it has */ } else { /* no it hasn't */ } } ?> <input type="checkbox" name="personal" value="checked" /> -
Just get angry on them birds.