Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. If you are quering two tables in different queries then you should look into normalizing your database so you can use SQL JOINS. With JOINS you can query multiple queries in one query. This is alot more easier than running two separate queries and trying to merge the results
  2. Change this: if(isset($_POST['delete'])) { // Delete it all mysql_query("TRUNCATE TABLE news")or die(mysql_error()); echo "All news deleted!<br><a href='test1.php'>Click here to check!</a>"; } } else { to: } elseif(isset($_POST['delete'])) { // Delete it all mysql_query("TRUNCATE TABLE news")or die(mysql_error()); echo "All news deleted!<br><a href='test1.php'>Click here to check!</a>"; } else { That should sort the problem. Also no need to connect/select database in each if statement. Just have one instance of that portion of code. So remove the following code: // Make a MySQL Connection mysql_connect("***", "***", "***") or die(mysql_error()); mysql_select_db("***") or die(mysql_error()); from your if blocks and chnage the following line: <?php if(isset($_POST['submit'])) { to <?php // Make a MySQL Connection mysql_connect("***", "***", "***") or die(mysql_error()); mysql_select_db("***") or die(mysql_error()); if(isset($_POST['submit'])) {
  3. Huh! Your question needs to be a bit more meaningful. I don't understand you at the moment.
  4. Is there more code to this? I cannot see how it is duplicating the rows from the database. Not unless your query is returning duplicate results maybe.
  5. In order for you to test your PHP scripts on your computer you'll need two vital components, which is PHP and a http server. Why a http server? PHP is a server sided scripting language which means your PHP scripts are parsed by the server. Whereas a simple HTML/CSS document is parsed by your web browser. Your browser will only receive the output of your PHP scripts which will generally be HTML/CSS and not the PHP code within your scripts. Before starting PHP make sure you have an understanding of HTML and CSS. You'll still need to use HTML/CSS to layout your webpages generated by PHP.
  6. Are you wanting to write the results returned from your SQL query to your CSV file. If so the following is not the correct way to do it: if ($csv==true) { $DOCUMENT_ROOT=$_SERVER['DOCUMENT_ROOT']; $output = implode.".".$result."\t\n"; $rf=fopen ("$DOCUMENT_ROOT/email.csv",'w+'); fwrite ($rf,$output, strlen($output)); fclose($rf); } } $result does not return anything. It only holds a Result Resource. What you'll want to do is add the following line: $csvData .= implode(',',$row) . "\n"; after: while($row = mysql_fetch_array($result)) { Now change $output = implode.".".$result."\t\n"; $rf=fopen ("$DOCUMENT_ROOT/email.csv",'w+'); fwrite ($rf,$output, strlen($output)); to: $rf=fopen ("$DOCUMENT_ROOT/email.csv",'w+'); fwrite ($rf,$csvData, strlen($csvData)); PHP should now populate your email.csv file with the results returned from your query.
  7. Has PHP5.3 been released yet? I cannot find any official docs from php.net about php5.3 or the mysqlnd extension. It maybe because you have two different versions of PHP installed on the same computer. Perhaps PHP5.2 is interfering with your PHP5.3 installation.
  8. Yes It has nothing to with what OS you have installed. You must use the correct module for the version of Apache you have installed.
  9. If you have fields which are set up as NOT NULL (meaning a value must be present in the field), they cannot have a default value, thus the error you are having. Only use DEFAULT when fields can have NULL values.
  10. jbodary please read my post
  11. From my testing its to do with how you have constructed your if/elseif/else statement. Use: if(isset($_POST["sendData"])) { $searchString = $_POST["sendData"]; if ($searchString == 1) $dataResults = "<h1>Hello Lilo!</h1>"; elseif ($searchString == 2) $dataResults = "<h1>Hello Stitch!</h1>"; elseif ($searchString == 3) $dataResults = "<h1>Hello Jumba!</h1>"; elseif ($searchString == 4) $dataResults = "<h1>Hello Pleakley!</h1>"; else $dataResults = "<h1>Aloha, cousin! Welcome to Hawaii!</h1>"; echo $dataResults; } No need for sprintf when defining strings.
  12. Yes you can. Use the date function $unixtime = strtotime('+5 days'); // get the unix timestamp 5 days from now // make time human readable echo date('d-m-Y', $unixtime);
  13. As far as I have read mysqlnd is a replacement for libmysql.dll. You should still need to enable php_mysql.dll (mysql_* functions) or php_mysqli.dll (mysqli_*) within the php.ini, in order to use the MySQL libraries in PHP5.3
  14. php5apache2_2.dll is for use with Apache2.2.x installations only. As you have Apache2.0.x installed you should use php5apache2.dll instead. You shoold keep all files that come with PHP contained within PHP's installation folder. You should add PHP to the Path Environment Variable (explainedunder the 3. Download and Install PHP 5 heading).
  15. That field is not seen. Users wont be able to modify the fields contents. That is why the field type is set to to hidden.
  16. Umm. How have you come to that conclusion! PHP is cross platform independent. It could be any number of things which was causing the error.
  17. It'll still work with more than one number, eg: mysite.com/tor/10053388 will call mysite.com/torrent_info.php?tor=10053388 Whatever is after tor/ in the url will be sent to torrent_info.php. All this is controlled by the following simple line in the .htaccess file: RewriteRule ^tor/([0-9]+)$ torrent_info.php?tor=$1 [L]
  18. You can't place a condition within a string. You only need to make sure $_POST['submit'] exists only once. You don't do it for all your form variables: <?php // being lazy $forename = $surname = $telephone = $email = $addressline1 = $city = $county = $postcode = null; if(isset($_POST['submit'])) { //$ownerid = $_POST['ownerid']; $forename = $_POST['forename']; $surname = $_POST['surname']; $telephone = $_POST['telephone']; $email = $_POST['email']; $addressline1 = $_POST['addressline1']; $city = $_POST['city']; $county = $_POST['county']; $postcode = $_POST['postcode']; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <p><b>Forename:</b> <input type="text" name="forename" size="20" value="<?php echo $forename; ?>"></p> <p><b>Surname:</b> <input type="text" name="surname" size="20" value="<?php echo $surname; ?>"></p> <p><b>Telephone:</b> <input type="text" name="telephone" size="20" value="<?php echo $telephone; ?>"></p> <p><b>Email:</b> <input type="text" name="email" size="20" value="<?php echo $email; ?>"></p> <p><b>Address:</b> <input type="text" name="addressline1" size="20" value="<?php echo $addressline1; ?>"></p> <p><b>City:</b> <input type="text" name="city" size="20" value="<?php echo $city; ?>"></p> <p><b>County:</b> <input type="text" name="county" size="20" value="<?php echo $county; ?>"></p> <p><b>Postcode:</b> <input type="text" name="postcode" size="20" value="<?php echo $postcode; ?>"></p> <input type="submit" name="submit" value="Add Owner"> </form>
  19. If your form contains text fields your browser will include these fields in the _POST data whether their value is empty or not. Fields in which you should check to see if they exists in the _POST data is checkbox, select and file fields. You should always check to see if $_GET data exists first before using it. The same applies to COOKIE too.
  20. <?php // check that the 'tor' parameter exists and that it holds a numeric value if(isset($_GET['tor']) && is_numeric($_GET['tor'])) { $tid = $_GET['tor']; // load the torrents.db file into the $torrents array // we use the line number as the torrent identifier $torrents = array_map('trim', file('torrents.db')); // check to see if the requested torrent identifier exists // we also check to see if the torrent hasn't been removed if(isset($torrents[$tid]) && ($torrents[$tid] != '-- removed --')) { // torrent identifier exists, get the info about the torrent list($description, $genre, $title) = explode('|', $torrents[$tid]); // now we display the torrent info in a simple HTML Table ?> <h1>Torrent Info</h1> <table border="0" cellspacing="2" cellpadding="5"> <tr> <th>Title</th> <td><?php echo $title; ?></td> </tr> <tr> <th>Genre</th> <td><?php echo $genre; ?></td> </tr> <tr> <th>Description</th> <td><?php echo $description; ?></td> </tr> </table> <?php } // torrent doesn't exist display error else { die('Torrent does not exist'); } } ?> RewriteEngine On RewriteRule ^tor/([0-9]+)$ torrent_info.php?tor=$1 [L] torrent1desc|torrent1genre|torrent1title -- removed -- torrent3desc|torrent3genre|torrent3title
  21. I presume you use a submit button to submit the form. If you name the submit you can use: <?php $self = $_SERVER['PHP_SELF']; // $_POST['[submit'] is the name of your forms' submit button if(isset($_POST['submit'])) { //$ownerid = $_POST['ownerid']; $forename = $_POST['forename']; $surname = $_POST['surname']; $telephone = $_POST['telephone']; $email = $_POST['email']; $addressline1 = $_POST['addressline1']; $city = $_POST['city']; $county = $_POST['county']; $postcode = $_POST['postcode']; // rest of your code } ?>
  22. What I'd do is actually use a flat file database rather than creating new instances of desc.txt, genre.txt and title.txt within a generated directory. I'd then use mod_rewrite so http://www.mysite.com/tor/1 will actually call http://www.mysite.com/torrent_info.php?tor=1 The torrent_info.php script will retrieve the torrent id number which it'll use to retrieve the information based on the torrent in the flat file database. Sounds complicated. But it is in fact relatively straight forward.
  23. Make sure you are saving the file in the correct encoding. I suggested ANSI (or ASCII). if you are saving it as UTF-8 make sure you save the file as UTF-8 without BOM.
  24. Just tested the code you posted with PHP and no errors where reported. Your script could do with some indentation so the code becomes more readable function my_func( --params-- ) { if( --condition-- ) { // your code } } Rather than: function my_func( --params-- ) { if( --condition-- ) { // your code } }
  25. There error is coming from /home/sgcrys5/public_html/include/sql.inc.php on line 1. Is the code you posted above from sql.inc.php
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.