Jump to content

UnrealEgg

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

UnrealEgg's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Got it solved. It seems like my database did not like the "desc" field so i renamed it to "description" and its working fine! Thank you for your support.
  2. Same error: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, link, date) VALUES('Carson out of England qualifier', 'Goalkeeper Scott Ca' at line 1
  3. Still the same error. could you post your new script ? <?php $doc = new DOMDocument(); $doc->load('http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/football/rss.xml'); $arrFeeds = array(); foreach ($doc->getElementsByTagName('item') as $node) { $itemRSS = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue ); array_push($arrFeeds, $itemRSS); } include 'dbconnect.php'; foreach ($arrFeeds as $item) { $sql="INSERT INTO tb_rss (title, desc, link, date) VALUES(" . mysql_real_escape_string($item['title']) . ", " . mysql_real_escape_string($item['desc']). ", " . mysql_real_escape_string($item['link']). ", " . mysql_real_escape_string($item['date']). ")"; if (!mysql_query($sql)){ die('Error: ' . mysql_error()); } } ?> Error: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, link, date) VALUES(Carson out of England qualifier, Goalkeeper Scott Carso' at line 1
  4. If I do that I get: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING I tried using "mysql_real_escape_string" already and its not working still. I looked at the article too and theres no quotes and stuff around where it says that error.
  5. Yeh, I noticed this myself but I am still getting the same error. Theres something up with the SQL query or something. I have no idea what it is though EDIT: Current status on the script: <?php $doc = new DOMDocument(); $doc->load('http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/football/rss.xml'); $arrFeeds = array(); foreach ($doc->getElementsByTagName('item') as $node) { $itemRSS = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue ); array_push($arrFeeds, $itemRSS); } include 'dbconnect.php'; foreach ($arrFeeds as $item) { $sql="INSERT INTO tb_rss (title, desc, link, date) VALUES ($item[title], $item[desc], $item[link], $item[date])"; if (!mysql_query($sql)){ die('Error: ' . mysql_error()); } } ?> Current error: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, link, date) VALUES (Carson out of England qualifier, Goalkeeper Scott Cars' at line 1
  6. Removed the bracket and still the same error.
  7. I have been trying very hard to get this script to work but I am no good at arrays... Anyhow, the basic idea is that the script will read an RSS feed and post all that content to the database which will be used to display content on the site. <?php $doc = new DOMDocument(); $doc->load('http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/football/rss.xml'); $arrFeeds = array(); foreach ($doc->getElementsByTagName('item') as $node) { $itemRSS = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue ); array_push($arrFeeds, $itemRSS); } include 'dbconnect.php'; foreach ($arrFeeds as $item) { $sql="INSERT INTO tb_rss (title, desc, link, date) VALUES ($item => title), $item => desc, $item => link, $item => date)"; if (!mysql_query($sql)){ die('Error: ' . mysql_error()); } } ?> Current error messege is: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc, link, date) VALUES (Array => title), Array => desc, Array => link, Array =' at line 1 Help please?
  8. A guy on another forum suggested this: if(isset($_POST['cmdsearch'])) { $search = $_POST['search']; if (@get_magic_quotes_gpc()) { $search = stripslashes($search); } foreach (glob("*") as $filename) { if (false !== stripos($filename, $search)) { echo $filename; echo "<br />"; } } } else { echo "<p>Please enter a search query.</p>"; } And it works! Only last problem now is to block certain key words such as php, index e.t.c. Any ideas?
  9. Fixed the * problem pretty easily by just adding a * after $search: foreach (glob("$search*") as $filename) { Now when I just Search Bear, it brings up Bear.wmv Last problems: Is there any way I can fix the case sensitive issue? Also, is there a way I can ban search phrases such as index, php, e.t.c.
  10. I got it working now, but the problem is you have to search like the following: *.wmv or Bear* Also, if I search bear* it does not bring anything up so it must be case sensitive. Any ideas how I can fix this so its not case sensitive and users don't have to put the * in? EDIT: If I search Bear.wmv it brings up the video as well.
  11. I tried that, but its just bringing up a blank screen as before ??? If you want to know where I got the script from, go here: http://www.bitrepository.com/web-programming/php/some-ways-to-scan-a-directory.html You may understand it more than what I do
  12. I have had a go at trying to make one and here is what I have so far. It inst working I don't think. <form name="search-form" id="search-form" method="post" action="searchphp.php" enctype="multipart/form-data" style="height: 103px"> <legend> <dl class="style2"> <dd class="style1"> <input tabindex="1" accesskey="b" name="search" type="text" id="search" /> </dd> </dl> <input tabindex="2" accesskey="l" type="submit" name="cmdsearch" value="Search" /> </form> php: <?php if(isset($_POST['cmdsearch'])) { $search = $_POST['cmdsearch']; foreach (glob("video/$search") as $filename) { echo $filename; echo "<br />"; }} else{ echo "<p>Please enter a search query.</p>"; } ?>
  13. I would like to try and make a search form that searches a directory of files. E.g. User inputs "video" in search bar, the search then returns: Bear_video.avi video butterfly.wmv video392.mpeg Also, once it finds the files they need to link to: view.php?url=name-of-file.wmv I asked on a different forum and they said to use glob() or strpos() but I have no idea how to set it up. Any ideas ???
×
×
  • 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.