
ryanwood4
Members-
Posts
100 -
Joined
-
Last visited
Everything posted by ryanwood4
-
I have a script which displays an image, but I now need a script which loads the next image. It simply needs to load a url with an id at the end which is one higher than the current, i.e. Current page: www.example.com/12 Then when you click 'next' it loads www.example.com/13 so it always needs to load +1. Not sure if this makes much sense tbh. Any help is appreciated.
-
Hi, Im trying to order results by the amount of reads they have received, but the results cannot be any older than 3 days, unless here isn't any to choose from in that date range, therefore it uses older results. For example: There are 4 items in the table: Item 1 | 59 reads | 24/11/2009 Item 2 | 22 reads | 23/11/2009 Item 3 | 63 reads | 23/11/2009 Item 4 | 99 reads | 18/11/2009 I want it to display Item 3, Item 1 and then Item 2. However say Item 1 wasn't there, then, because there are only 2 items within a 3 day period it uses the next most recent item. I have the simple structure but can't think how to do the above: <?php $con = mysql_connect("localhost","xxxx","xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxx", $con); $result = mysql_query("SELECT * FROM members ORDER BY reads ASC limit 3"); echo "<table border='0' width='100%'>"; while($row = mysql_fetch_array($result)) { echo '<tr><td><img class="scaled" src="'.$row['image'].'"/></td>'; echo '<td><h6><a href="community/display/'.$row['id'].'">'.$row['title'].'</a></h6>'; echo '<p>Reads: '.$row['reads'].'</p></td></tr>'; } mysql_close($con); ?> Thanks in advance.
-
Solved it, there was an elusive ']' in the date string. Thanks to everyone who helped.
-
Yeah Is $_POST['submit'] is set, and the else is for when the page is submitted, the message: 'Article Posted' comes up. Would it help if I posted the entire html script?
-
Im trying to submit a form using this script, however nothing shows up on the page, does anyone know why it's not working? Thanks <?php // Connects to your Database mysql_connect("localhost","xxxx","xxxx") or die(mysql_error()); //CHANGE ME BACK!!!!! mysql_select_db("xxxx") or die(mysql_error()); //This code runs if the form has been submitted if (isset($_POST['submit'])) { $date = date("y-m-d H:i:s"); $insert = sprintf("INSERT INTO members set title = '%s' , body = '%s', image = '%s', category = '%s', date = '%s' ", mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['body']), mysql_real_escape_string($_POST['image']), mysql_real_escape_string($_POST['category']), mysql_real_escape_string($date]) ); $add_member = mysql_query($insert) or die(mysql_error()); ?> <p>Article posted</p> <?php } else { ?>
-
Getting around apostrophe problem in forms - help please.
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
Nope, nothing is displaying on the page now. This is a harder to solve problem than I thought. -
Getting around apostrophe problem in forms - help please.
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
Nope, that's not working either: <?php // Connects to your Database mysql_connect("localhost","xxxx","xxxx") or die(mysql_error()); //CHANGE ME BACK!!!!! mysql_select_db("xxxx") or die(mysql_error()); //This code runs if the form has been submitted if (isset($_POST['submit'])) { $date = date("y-m-d H:i:s"); // now we insert it into the database $insert = sprintf("INSERT INTO members set title = '%s' , body = '%s', image = '%s', category = '%s', date = '%s' ", mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['body']), mysql_real_escape_string($_POST['image']), mysql_real_escape_string($_POST['category'])); $add_member = mysql_query($insert); ?> <p>Article posted</p> <?php } else { ?> -
Getting around apostrophe problem in forms - help please.
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
This is the new code, which didn't work though. <?php // Connects to your Database mysql_connect("localhost","xxxx","xxxx") or die(mysql_error()); //CHANGE ME BACK!!!!! mysql_select_db("xxxx") or die(mysql_error()); //This code runs if the form has been submitted if (isset($_POST['submit'])) { $date = date("y-m-d H:i:s"); // now we insert it into the database insert = sprintf("INSERT INTO members set title = '%s' , body = '%s', image = '%s', category = '%s', date = '%s' ", mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['body']), mysql_real_escape_string($_POST['image']), mysql_real_escape_string($_POST['category'])); ?> <p>Congrats!</p> <?php } else { ?> -
Getting around apostrophe problem in forms - help please.
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
That's not adding anything to the database now, even without apostrophe's. -
Getting around apostrophe problem in forms - help please.
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
How do I do this? Im new to PHP (learning slowly) and only discovered this 'mysql_real_escape_string()' today. The only input which is causing problems is the 'title' input - how do I go about implementing the mysql_real_escape_string? Thanks -
Hi, I am using a form to submit articles to a database, but when I add an apostrophe (') in the title it doesn't add the data, however without an apostrophe it does. This is the code im using: <?php // Connects to your Database mysql_connect("localhost","xxxx","xxxx") or die(mysql_error()); //CHANGE ME BACK!!!!! mysql_select_db("xxxx") or die(mysql_error()); //This code runs if the form has been submitted if (isset($_POST['submit'])) { $date = date("y-m-d H:i:s"); // now we insert it into the database $insert = "INSERT INTO members (title,body,image,category,date) VALUES ('$_POST[title]','$_POST[body]','$_POST[image]','$_POST[category]','$date')"; $add_member = mysql_query($insert); ?> <p>Congrats!</p> <?php } else { ?> How can I get around this problem? I heard about this: mysql_real_escape_string - but have no idea how to implement it in the code. Would really appreciate some help. Thanks in advance.
-
Try this: <?php if (isset($_REQUEST['email'])) //if "email" is filled out, send email { //send email $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; mail( "[email protected]" , "Subject: $subject", $message, "From: $email" ); echo "Thank you for using our mail form"; } else //if "email" is not filled out, display the form { echo "<form method='post' action='mailform.php'> Email: <input name='email' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' /> </form>"; } ?>
-
I'm using the below code to fetch the most recent 24 articles stored in the database. However, I need to change it, so it only fetches posts from the current day. So for example, today it would fetch the 15th October 2009 results, and tomorrow the 16th's. Is this possible? <?php $con = mysql_connect("xxxx","xxxx","xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxx", $con); $result = mysql_query("SELECT * FROM n2s_article ORDER BY article_id DESC LIMIT 0,23"); 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); ?>[/code Thanks.
-
Easier description, how do you add all the figures in a column, and then do that for each column and display those results?
-
I am trying to create a database containing results from races. Each driver has a column in a table, which records how many points they got in each race. The races are ordered as 1,2,3... under the id column. I want to show the results, but am struggling to find a way to make them add up. The code i'm using displays the first results for each driver, but I want to add up all the figures in each column for each driver so it gives a total of their points. <?php $con = mysql_connect("xxxx","xxxx","xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxx_championship", $con); $result = mysql_query("SELECT * FROM wdc ORDER BY id"); while($row = mysql_fetch_array($result)) { $alonso = $row['alonso']; $alguersuari = $row['alguersuari']; $badoer = $row['badoer']; $barrichello = $row['barrichello']; $buemi = $row['buemi']; $button = $row['button']; $fisichella = $row['fisichella']; $glock = $row['glock']; $grosjean = $row['grosjean']; $hamilton = $row['hamilton']; $heidfeld = $row['heidfeld']; $kovalainen = $row['kovalainen']; $kubica = $row['kubica']; $massa = $row['massa']; $nakajima = $row['nakajima']; $piquet = $row['piquet']; $raikkonen = $row['raikkonen']; $rosberg = $row['rosberg']; $sutil = $row['sutil']; $trulli = $row['trulli']; $vettel = $row['vettel']; $webber = $row['webber']; $liuzzi = $row['liuzzi']; $bourdais = $row['bourdais']; } mysql_close($con); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" > <head> <title>The F1 Times</title> </head> <body> J. Button <?php echo $button; ?><br /> R. Barrichello <?php echo $barrichello; ?><br /> M. Webber <?php echo $webber; ?><br /> S. Vettel <?php echo $vettel; ?><br /> K. Raikkonen <?php echo $raikkonen; ?><br /> N. Rosberg <?php echo $rosberg; ?><br /> L. Hamilton <?php echo $hamilton; ?><br /> F. Alonso <?php echo $alonso; ?><br /> F. Massa <?php echo $massa; ?><br /> J. Trulli <?php echo $trulli; ?><br /> T. Glock <?php echo $glock; ?><br /> R. Kubica <?php echo $kubica; ?><br /> N. Heidfeld <?php echo $heidfeld; ?><br /> S. Buemi <?php echo $buemi; ?><br /> K. Nakajima <?php echo $nakajima; ?><br /> H. Kovalainen <?php echo $kovalainen; ?><br /> T. Liuzzi <?php echo $liuzzi; ?><br /> A. Sutil <?php echo $sutil; ?><br /> G. Fisichella <?php echo $fisichella; ?><br /> N. Piquet<?php echo $piquet; ?><br /> J. Alguersuari <?php echo $alguersuari; ?><br /> L. Badoer <?php echo $badoer; ?><br /> S. Bourdais <?php echo $bourdais; ?><br /> R. Grosjean <?php echo $grosjean; ?><br /> </body> </html> Any help is greatly appreciated, i'm pretty new to PHP. Thanks.
-
[SOLVED] Displaying images stored in database
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
Oh, I think it may be a permission thing. Thanks Bricktop! -
[SOLVED] Displaying images stored in database
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
Ahah, that solved the error. Thanks. Still one problem, them images aren't displaying, but they are linking correctly. The page - http://www.f1times.co.uk/gallery_mini.php -
Hi, I'm using the code I wrote below - (I'm a novice, so it could be completely wrong) - to display images which are stored in a folder on a server. The url to the images are kept in a database: gallery2, table: g2_FileSystemEntity column: g_pathComponent But I can't seem to make it work. I want the code to display an image, and link to the larger image in the gallery. The gallery url for each image starts: http://www.f1times.co.uk/gallery2/gallery2Embedded.php?g2_itemId= and then after the equals each image has a unique id. This is under g_id column. This is what I want the image to link to when clicked. The images themselves are stored here: ttp://www.f1times.co.uk/gallery2/g2data_b0f3726a/albums/ (the image file name is stored in the database I mentioned above) Any help would be very helpful. <?php $con = mysql_connect("xxxx","xxxx","xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("f1times_gallery2", $con); $result = mysql_query("SELECT * FROM g2_FileSystemEntity ORDER BY g_id DESC LIMIT 0,1"); while($row = mysql_fetch_array($result)) { $url = "http://www.f1times.co.uk/gallery2/gallery2Embedded.php?g2_itemId=" . $row['g_id']; $image = "http://www.f1times.co.uk/gallery2/g2data_b0f3726a/albums/" . $row['g_pathComponent']; echo "<a href='$url' target=_parent>"."img src="($row['$image'])."</a>"; } mysql_close($con); ?></tr></table>
-
[SOLVED] Returning results using keywords search
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
Genius. Thank you very, very, very much for all your help. Ryan. -
[SOLVED] Returning results using keywords search
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
Adding OR '%Arrows%' doesn't work, it only shows results containing the first keyword 'Silver' -
[SOLVED] Returning results using keywords search
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
Great Success! Thanks, Bricktop and gevans. The problem was articles' weren't matching all the keywords. How do I make it so it's Silver or Mercedes or Arrow, rather than Silver, Mercedes and Arrow? -
[SOLVED] Returning results using keywords search
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
Thanks, that has solved the error, but the page isn't showing any results, it's just blank. -
[SOLVED] Returning results using keywords search
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
Still 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 <?php $con = mysql_connect("xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("f1times_articles", $con); $result = mysql_query("SELECT * FROM n2s_article WHERE 'article_title,article_content' LIKE '%Silver%' or WHERE 'article_title,article_content' LIKE '%Arrow%' or WHERE 'article_title,article_content' LIKE '%Mercedes%' 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); ?> I can't think of a reason as to why it won't work though. Thanks -
[SOLVED] Returning results using keywords search
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
Do I need to add a FULLTEXT query to the simpler version you suggested? If not, I tried that and still get the same error. -
[SOLVED] Returning results using keywords search
ryanwood4 replied to ryanwood4's topic in PHP Coding Help
I added that in beforehand, and got the same error.