Jump to content

theweirdone

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

theweirdone's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, so it turns out it was a problem with the validation. Because the date wasn't in the 'Y-m-d' format, it wouldn't pass validation, and therefore wouldn't save. Thanks for the help though.
  2. Hi, I'm pretty new to CakePHP, and have been managing so far. I've created a scraper that scrapes TV.com for episode information (episode number, airdate, title, description). The scraper works fine, and returns an array such as: Array ( [0] => Array ( [name] => Stowaway [number] => 17 [description] => No synopsis available. Write a synopsis. [date] => 3/18/2011 [show_id] => 11 ) [1] => Array ( [name] => Os [number] => 16 [description] => While Walter attempts to figure out a way to stop the spread of vortexes on This Side, the team investigate a series of thefts committed by criminals who can control gravity. [date] => 3/11/2011 [show_id] => 11 ) ) The array is definately there, because I can print_r it. On to the controller. The controller is called episodes_controller, and has the usual CRUB actions, plus the scraper. I've added an action called addAll which calls the scraper and then is meant to save the array into the database using a foreach loop. Here's the code: function addAll($id = null) { if (!$id) { $this->Session->setFlash(__('Invalid show id entered', true)); //$this->redirect('/episodes'); } $show = $this->requestAction('/shows/getTvById/'.$id); //gets the tv.com url $episodes = $this->scrape($show, $id); //scrapes tv.com for the show $this->set('episodes', $episodes); //sets $TVshowInfo for the view $count = 0; foreach ($episodes as $episode) { $this->Episode->set($episode); if($this->Episode->save()){ $count++; } } $this->Session->setFlash(__($count.' episodes were saved.', true)); //$this->redirect('/episodes'); } Every time I run it, the Flash message say's 0 episodes saved. I've tried variations such as if ($this->Episode->save($episode)){ with the same result. Any suggestions would be welcome. Thanks.
  3. I dont really understand what it is your asking. I have read through the code though, and there is no need to repear "[color=blue]if ($access == "1")[/color]" so many times, and you didn't spell [color=blue]SESSION[/color] correctly when you echo $_SESSION['first_name']. Here's the adjusted code. Not sure if it helps with what you were asking...: [code] <? /* start the session */ session_start(); /* error handle, if first_name is blank, make them sign in */ if(empty($first_name)){ print "Please login below!"; include 'login_form.html'; }else{ /* heres our trusty db.php file again */ include 'db.php'; /* checking users access */ /* heres what prints at the top of the page, change as needed */ echo "Welcome, ". $_SESSION['first_name'] .". You are now in our exclusive 'Members Only' section. <br>The material in this section is availible to Members <u><b>only.</b></u><br>It's purpose is to let our valued Members have access to inside informaiton before it is made public. <br><b>Use of this area is strictly monitored. Unauthorized access will be prosecuted under the fullest extent of the law.</b><br><br>"; /* Roster List */ echo "<title>Members Section</title><br><br><br><h3><b>Roster:</b></h3>"; include 'login_success_roster.php'; /* Matches Section */ echo "<br><br><br><h3><b>Matches:</b></h3>"; include 'login_success_matches.php'; /* Media Section */ echo "<br><br><br><h3><b>Media:</b></h3>"; include 'login_success_media.php'; /* Sponsors Section */ echo "<br><br><br><h3><b>Sponsors:</b></h3>"; include 'login_success_sponsors.php'; /* ProShop Section */ echo "<br><br><br><h3><b>ProShop:</b></h3>"; include 'login_success_proshop.php'; /* Forums Section */ echo "<br><br><br><h3><b>Forums:</b></h3>"; include 'login_success_forums.php'; } if($access == "1"){ echo "<br><br><li><a href=roster_update_form.php>Edit Roster</a>"; echo "<br><br><li><a href=matches_update_form.php>Edit Matches</a>"; echo "<br><br><li><a href=media_update_form.php>Edit Media</a>"; echo "<br><br><li><a href=sponsor_update_form.php>Edit Sponsors</a>"; echo "<br><br><li><a href=proshop_update_form.php>Edit ProShop - Comming Soon</a>"; echo "<br><br><li><a href=forum_update_form.php>Edit Forum - Comming Soon</a>"; } echo "<br><br><br><b><a href=logout.php>Logout</a><br>"; print "<br><br><br><br>"; ?> [/code]
  4. So I have another problem. What I'm pretty much trying to do is to make a program that displays text. So I've made a function to do this, because it extracts the text from the file "songs.inc". The songs are formatted in the file in this way: "Song Title#", (using the # to split the songs up). Here's the function that's meant to display the songs: [code] function display_songs($file_path) { $all_songs = fopen($file_path, "r"); $songs = explode("#", $all_songs); $songs = str_replace("#", "<br />", $songs); $song_count = count($songs); for ($i = 0; $i <= $song_count; $i += 1) { echo "$songs[$i] In My Pants"; } } [/code] When I run the code though, all it displays is [quote]Resource id 4 Notice: Undefined offset: 2 in c:\program files\easyphp1-8\www\in my pants\includes\functions.inc.php on line 41[/quote] Any Ideas?
  5. that will work nicely... thanx...
  6. Ok, so what I'm trying to do is to check a string ($song) for apostrophes (donno how to spell it, this thing: " ' ") and put a backslash in front of it... I'm not too sure about how I go around doing it. I've created a function which is suppose to break up the string into an array. I'm having trouble with this, I've tried using split(), but I don't want it to split with a pattern, I want it just to split every character into a seperate subset of the array.. Is that possible, or is there another way for me to go about doing this? Any help is appreciated...
  7. Still doesn't work... I don't get it... Here's the code to add songs, it might help find the problem... [code] <?php include("dogs.inc.php"); $song_title = $_GET['song_title']; mysql_connect($host,$username,$password); mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO Songs (song_title) VALUES ('$song_title')"; mysql_query($query) or die("Unable to do query"); echo "Song $song_title has been added successfully"; mysql_close(); ?> [/code] Hope it helps find the problem...
  8. Sorry, should have been more specific. The thing is, it's suppose to display song titles in the database, but nothing shows, it's blank. I took off the '@', but it still shows nothing. I also renamed 'dogs.inc' to 'dogs.inc.php', and that doesn't help either. I've read through the code a few times, and I can't find the error. Would it help if I showed the code that adds songs to the database? Cause that works fine...
  9. Hey, I'm having some trouble with this code: [code]<?php include("dogs.inc"); mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "SELECT song_title FROM Songs"; $results = mysql_query($query); while($row = mysql_fetch_assoc($query)){ echo "$row['song_title']"; } mysql_close(); ?>[/code] This is in a file called all_songs.inc which is being called by a file called index.php. I can't find the problem. The variables $host, $username, $password and $database are all being stored in the file dogs.inc. I know that they are correct, because i have another file adding files to the database, and it works fine. The database has one table called Songs, with two fields: song_id and song_title. I've tried using the functions mysql_fetch_assoc and mysql_fetch_array. Should I be using a different one? Anyone have any ideas? Oh, and what does the "@" in front of mysql_select_db do? Thanx
  10. never mind... found a solution incase anyone needs this someday... just changed position to relative, and put it in actual order, so that it's more "natural"...
  11. Right, so my problem is that the site I'm working on works fine showing certain pictures on Firefox and Opera, but doesn't work at all on IE... Here's the source of what won't show: [code]<div id="sponsors"> <a href="http://www.alprosoja.com" target="_blank"><img src="images/sponsors/Alpro-soya-logo-3D-R.png" border="0" class="sponsors" /></a><a href="http://www.capfi.be" target="_blank"><img src="images/sponsors/capital-finance.png" border="0" class="sponsors" /></a><a href="http://www.degroof.be" target="_blank"><img src="images/sponsors/Degroof.png" border="0" class="sponsors" /></a> <a href="http://www.emilierolin.com" target="_blank"><img src="images/sponsors/emilie-rolin.png" border="0" class="sponsors" /></a><a href="http://www.b-a.be" target="_blank"><img src="images/sponsors/Bruxelles-Animation-logo.png" border="0" class="sponsors" /></a> </div> [/code] Here's the css source for sponsors: [code]#sponsors{     position: absolute;     top: 170px;     right: 360px;     width: 500px; } #sponsors img{     margin-left: 20px; } [/code] Hope someone can help...
  12. Hi, I've made a site using php, and uploaded it onto the server (a .be site), yet when I try to go on it, all that is shown is: "500 phpwrapper internal error : ERR_MISSING_CGI_PRIVILEGE (45)". I searched this on google, and found five results, and interestingly, most of them were .be and .nl sites. Didn't find any help though, could anyone here help? thanx...
×
×
  • 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.