Jump to content

ryanwood4

Members
  • Posts

    100
  • Joined

  • Last visited

Everything posted by ryanwood4

  1. I'm getting this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/f1times/public_html/mclaren_news.php on line 24
  2. Hi, Static keywords. Thanks.
  3. I'm using this basic code to display a list of recent articles, taken from a database. However, I'd like to change it, so it only displays links to articles with certain keywords in the title/body of the article. Is this possible. <?php $con = mysql_connect("xxxx","xxxx","xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("f1times_articles", $con); $result = mysql_query("SELECT * FROM n2s_article ORDER BY article_id DESC LIMIT 0,10"); echo "<table class='links' border='0'> <tr> <th></th> </tr>"; while($row = mysql_fetch_array($result)) { $url = $row['article_url'] . "-" . $row['article_id'] . ".html"; echo "<tr>"; echo "<td class='link'><font face='verdana' size='1pt'>ยป <a href='$url'>".stripslashes($row['article_title'])."</a></td>"; } mysql_close($con); ?> Example: Currently it displays the latest 10 articles. I would like it, so it displays the latest 10 articles, but only ones which contain the words: Silver, Arrow, Mercedes. Any help is appreciated, as my knowledge of PHP is minimal. Thanks.
  4. That worked a treat! Thanks.
  5. I really don't get what I need to change. I added some spaces between: WHERE email = '$email' which cured the error, but the email still doesn't show the member_id
  6. // now we insert it into the database $insert = "INSERT INTO member_id (forename, surname, email) VALUES ('$_POST[forename]','$_POST[surname]','$_POST[email]')"; $add_member = mysql_query($insert); $memberQuery = SELECT member_id FROM member_id WHERE email='$email' $memberResults = mysql_fetch_assoc($memberQuery); $email = $_POST["email"]; $forename = $_POST["forename"]; $surname = $_POST["surname"]; $member_id = $_POST["member_id"]; This is what I have tried, but I get this: Parse error: syntax error, unexpected T_STRING in /home/f1times/public_html/mobile/sign_up1.php on line 34
  7. How do I force it to start at 10001
  8. Would you mind elaborating on the code I need to insert a little. Im pretty useless with PHP, everything I tried, doesn't seem to work.
  9. Thanks, but where abouts do I add this?
  10. I have this php code, which allows members to sign-up, and then receive an email containing their details. However, I want the email to contain their member ID, this figure is automatically created in the MySQL table as an auto-increment primary key. How do I add this to the email? <?php // Connects to your Database mysql_connect("xxxx", "xxxx", "xxxx") or die(mysql_error()); mysql_select_db("f1times_comp") or die(mysql_error()); //This code runs if the form has been submitted if (isset($_POST['submit'])) { //This makes sure they did not leave any fields blank if (!$_POST['forename'] | !$_POST['surname'] | !$_POST['email']) { die('You did not complete all of the required fields. Click back in your browser to return.'); } // checks if the email is in use if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $usercheck = $_POST['email']; $check = mysql_query("SELECT email FROM member_id WHERE email = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the email exists it gives an error if ($check2 != 0) { die('Sorry, the email '.$_POST['email'].' is already in use. Click back in your browser to return.'); } // now we insert it into the database $insert = "INSERT INTO member_id (forename, surname, email) VALUES ('$_POST[forename]','$_POST[surname]','$_POST[email]')"; $add_member = mysql_query($insert); $email = $_POST["email"]; $forename = $_POST["forename"]; $surname = $_POST["surname"]; $to = "$email"; $subject = "The F1 Times - Member ID"; $MsgHeader = "From: The F1 Times <[email protected]>\n"; $MsgHeader .= "MIME-Version: 1.0\n"; $MsgHeader .= "Content-type: text/html; charset=iso-8859-1"; $MsgBody = " <html> <head> <title>Your Member ID</title> </head> <body> <table style='padding-left:0px' style='padding-top:0px'> <tr><td align='left'><img src='http://www.website.com/pix/logo.gif'></td></tr> </table> <table style='margin-left:12px'> <tr><td> </td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>$forename, your registration has been received by Sherbet Clothing.</font></td></tr> <tr><td> </td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Your Email: $email</font></td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Your Member ID: $member_id</font></td></tr> <tr><td> </td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Best Regards</font></td></tr> <tr><td> </td></tr> <tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>The F1 Times</font></td></tr> <tr><td> </td></tr> <tr><td><font style='font-size: 11px' style='font-family: Tahoma, Arial'>This message has been automatically generated please do not reply.</font></td></tr> <tr><td> </td></tr> <tr><td> </td></tr> </table> <table style='margin-left:12px' style='margin-right:250px'> <tr><td><font style='color: #336699' style='font-size: 10px' style='font-family: Tahoma, Arial'>This message, and any attachments, is intended only for the use of the individual or entity to which it is addressed, and may contain confidential, proprietary and/or privileged information that is exempt from disclosure under applicable law which is not waived or lost by any transmission failure. If the reader of this message is not the intended recipient or its employee, or agent responsible for delivering the message to the intended recipient, you are hereby notified that any use, dissemination, distribution or copying of this communication and any attachments hereto is strictly prohibited. If you have received this communication in error, please destroy this message. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorised to state them to be the views of another person or entity.</font></td></tr> </table> </body> </html>"; mail($to, $subject, $MsgBody, $MsgHeader); ?> <p>You will shortly receive an email containing your information.</p> <?php } else { ?> <div id="stylized" class="myform"> <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <h1>Sign-up</h1> <label>First Name <span class="small">Enter your first name</span> </label> <input type="text" name="forename" id="textfield" /> <label>Surname <span class="small">Your known as?</span> </label> <input type="text" name="surname" id="textfield" /> <label>Email <span class="small">Enter a valid email</span> </label> <input type="text" name="email" id="textfield" /> <button input type="submit" name="submit" value="Register">Register</button> <div class="spacer"></div> </form> </div> <?php } ?> Thanks in advance.
  11. This may be a fairly simple question, but I can't figure it out. I have an auto-increment ID column, which counts up in single digits, i.e. 0,1,2,3,4... How do I make it, so it counts up like this: 00001,00002,00003,00004... Thanks.
  12. I'm using this to create my list if links. Which works great. <?php $con = mysql_connect("localhost","xxxx","xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("f1times_articles", $con); $result = mysql_query("SELECT * FROM n2s_article ORDER BY article_id DESC LIMIT 0,5"); while($row = mysql_fetch_array($result)) { $url = $row['article_url'] . "-" . $row['article_id'] . ".html"; echo "<li><a href='$url'><span class='name'>".stripslashes($row['article_title'])."</a></span></li>"; } mysql_close($con); ?> I need it, so when you click a link, it opens a page, containing the article which relates to that link. My database structure looks like this: table name: n2s_article Column 1: article_ID column 2: article_url column 3: article_title column 4: article_content
  13. Okay, I'm not quite sure how to explain this one. I have a list of links, which all have a unique url. The url is stored in a table with other information such as an image, article text, etc. When someone clicks the link, I want the information which is in the same row as the unique URL to be displayed on a page. So if they then click the link below, it displays the information in that links row. I can't explain it, but if anyone is on MSN and would like to help (I will happily pay for your time) then add me: [email protected] or email me. Thanks
  14. Ok, but where do I add the connection to the database? Thanks.
  15. Hi, how do I get my pages to display a dynamic page title? I want the title at the top to say The F1 Times | <then here the title of the article> but because all the articles pass through the 'index.php' page I am having difficulty. I have tried a few options, all of which have failed. The database is called: 'f1times_articles' and the table: 'n2s_article', the title I want displayed comes under the column 'article_title' this has flummoxed me. Sorry if this doesn't make much sense - had difficulty explaining it. Thanks in advance.
  16. Thanks, now I know where I was going wrong!
  17. Hi, I'm trying to display the date an article was published. They are saved to a database, with the date stored as a 'timestamp' under the column: 'article_timestamp' but I want the date displayed in a readable format such as 'DD-MM-YY 00:00:00' I have created the code so far which calls the article titles, and put them in a list, but am having trouble with the dates. This is the page so far: http://www.f1times.co.uk/archive.php <?php $con = mysql_connect("localhost","xxxx","xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("f1times_articles", $con); $result = mysql_query("SELECT * FROM n2s_article ORDER BY article_id DESC LIMIT 21,35"); echo "<table border='0'> <tr> <th></th> </tr>"; while($row = mysql_fetch_array($result)) { $url = $row['article_url'] . "-" . $row['article_id'] . ".html"; echo "<tr>"; echo "<td><h5><a href='$url'>".stripslashes($row['article_title'])."</h5></a></td>"; } mysql_close($con); ?> I really have no clue where to go from here, everything I have tried hasn't worked, any help is greatly appreciated. Thanks in advance.
  18. Well that was simple, thanks. I tried the html version target="_parent" so I was almost there. Cheers
  19. I need the link below to open in the parent window, is this possible, and how would I go about it. Code Snippet: echo "<td><h7><b><a href='$url'>".stripslashes($row['article_title'])."</h7></b></a>"; Full Code: <?php $con = mysql_connect("localhost","xxxx","xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("f1times_articles", $con); $result = mysql_query("SELECT * FROM n2s_article ORDER BY article_id DESC LIMIT 1,3"); echo "<table border='0'> <tr> </tr>"; while($row = mysql_fetch_array($result)) { $url = $row['article_url'] . "-" . $row['article_id'] . ".html"; echo "<tr>"; echo "<td><h7><b><a href='$url'>".stripslashes($row['article_title'])."</h7></b></a>"; echo "<p>".stripslashes($row['article_teaser'])."<br /></p></td>"; } mysql_close($con); ?> Thanks
  20. haha, I wasn't! Thank you so very much, its sorted!
  21. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/f1times/public_html/titles.php on line 37 I get this error when using the above suggestion.
  22. That seems to just add the word stripslashes before the result.
  23. I need to strip the slashes from article_title and article_teaser, how do I do this? <?php $con = mysql_connect("localhost","xxxxx","xxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("f1times_articles", $con); $result = mysql_query("SELECT * FROM n2s_article ORDER BY article_id DESC LIMIT 0,15"); echo "<table border='0'> <tr> <th>Latest News</th> </tr>"; while($row = mysql_fetch_array($result)) { $url = $row['article_url'] . "-" . $row['article_id'] . ".html"; echo "<tr>"; echo "<td><h2><a href='$url'>{$row['article_title']}</h2></a>"; echo "<p>{$row['article_teaser']}</p></td>"; } mysql_close($con); ?> Thanks in advance.
  24. Thanks to everyone, your very generous with your time!
  25. Thanks for the help, I tried both but get an error: Parse error: syntax error, unexpected $end in /home/f1times/public_html/titles.php on line 21 Using this code: <?php $con = mysql_connect("localhost","private","private"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("f1times_articles", $con); $result = mysql_query("SELECT * FROM n2s_article ORDER BY article_id DESC LIMIT 0,20"); while($row = mysql_fetch_array($result)) { $url = $row['article_url'] . "-" . $row['article_id'] . ".html"; echo "<a href='$url'>{$row['article_title']}</a>"; // if(file_exists($fileurl)){echo "<a href='<?= $fileurl; ?>'>$row['article_title']</a>";}else{echo "NO FILE AVAILABLE";} //<- Try this to check to make sure the file exists. echo "<br />"; } mysql_close($con); ?>
×
×
  • 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.