Jump to content

[SOLVED] Data Wont Insert


papaface

Recommended Posts

Hello,

Can someone explain to me why this doesnt work:

	move_uploaded_file($_FILES['file']['tmp_name'],"/***/".$_FILES['file']['name']);
$title = $_POST['title'];
$content = $_POST['news'];
$author = $_POST['author'];
$date = date("Y-m-d H:i:s");
$image_path = "/***//".$_FILES['file']['name'];
$insert_news = mysql_query("insert into news (news_title,news_content,news_author,date,image_path) values ('{$title}','{$content}','{$author}','{$date}','{$image_path}')",$conn);
if	($insert_news)
	{?>
	<a href="../addnews.php">The news item has been added successfully. Click here to go back.</a>
<?php
	}
else
	{?>
	<a href="../addnews.php"><?php echo $content; ?>There was a problem adding the news. Click here to go back.</a>
<?php
	}

I get "There was a problem adding the news. Click here to go back." printed everytime. I have worked out it is $_POST['news'] that is causing the problem.

The mysql column is LONGTEXT and what I am trying to enter has some HTML in.

When i use PHPMYADMIN it inserts fine so I know its not a problem with mysql, its something to do with the PHP side.

Link to comment
Share on other sites

i wanted to see if the data was being posted as

<h5>Bungie Weekly Update </h5>

or

<h5>Bungie Weekly Update </h5>

 

addslashes shouldn't do that

 

OK combo time

 

in addition to what you have.

use

html_entity_decode($fromDB);

 

this WILL translate to html

Link to comment
Share on other sites

 <h5>Bungie Weekly Update </h5>
            <h6>Posted by <a href="http://www.bungie.net/Account/Profile.aspx?uid=6662">Frankie</a> at 4/27/2007 2:28 PM PDT</h6>
                        <strong> Friday, April 27th, 2007 </strong> <br />
                  <br />
                There’s an ancient Chinese curse that says, “May you live in  interesting times.” What I wouldn’t give for a week of boring times.  Mind you, an ancient Chinese proverb also says you can’t find ivory in  a dog’s mouth. What is <em>that</em> all about?<br>
               <br>
              There have been a number of irritating problems for folks trying to  download the Halo 2 "Blastacular" maps this week, and for that reason,  we have delayed the rollout of the Matchmaking update (and the  accompanying rank reset) until next week. We’ve actually figured out  why some folks are still having difficulty downloading the maps, and in  most cases, those folks probably have some inkling of why their chosen  method of getting the maps might have failed…<br>
              Some people have reported on various forums that there was initially  a glitch in the billing system that allowed people to download the  Blastacular maps for free. This bug was quickly fixed but anyone who  still attempts to circumvent the billing system will actually end up  locking themselves out of the maps entirely with no way to download  them. The Xbox Live team is pursuing a fix to enable downloads again  for these vagabonds, ne’er-do-wells and hooligans. <br />
                  <br />
                In a few  other cases, the problem is caused by a kind of disconnect between this  generation of Xbox Live and last, as far as age ratings are concerned.  Basically the system thinks you’re too young, even if you’re not. Those  problems are being fixed as we speak. Again, the reason this has been a  less than perfect transition has an awful lot to do with insisting that  the maps are made available to both 360 and olde Xbox owners. It has  never really been done before, so we apologize for our teething  troubles. <br>
              Most of our multiplayer activity recently has revolved around  testing the Public Beta. As some of you may already know, an internal  Microsoft Beta has been running for a while. We’re using that for a  very different set of tests than the public version. Number one among  those tests is scale.<br>
              We have to make sure that Halo 3 scales well to a large population,  and that will help us improve and test our netcode, as well as try out  one more feature that we’re including in the Beta. A feature that  definitely requires a lot of stress testing in a big population.  Conspiracy theorists can drop their 128-player game theories at the  door. Halo 3 is still a 16-player game, and the reality is that most  people prefer smaller games than that. <br>
              No, this feature we’re testing is for the moment, just a fun  addition, that’s planned to grow into something pretty amazing by  launch, and that feature is Saved Films. The version you’ll try in the  Beta, is very, very, very limited. We just want you to play around with  the general concept. You’ll be reading more about this in the gaming  press in the next month or two, and of course you can try it out for  yourselves in less than a month.<br>
              As for the Public Beta itself, it’s pretty close to finished and a  lot of folks have worked really hard to make it happen, with late  nights, early mornings and a constant diet of Cheetos and evil. So to  those brave men and women who sacrificed themselves on the Anvil of  Bungie, under the Hammer of Crunch, we salute thee. Your smeared  remains will be remembered.<br>
              Although the Public Beta may seem like a simple sampling of the MP  levels from the finished game, extracting those and packaging them into  a playable bundle, with off-schedule bug testing, gameplay tweaks, code  fixing and netcode support, is a herculean task. Hopefully it will pay  dividends and players will get tremendous enjoyment from these maps and  game types.<br>
              Since we’re testing matchmaking, you won’t have the kind of control  you’re used to with custom games, but we’ll be there to guide you into  a very nice selection of Matchmade game types – and don’t worry, the  playlists will almost certainly have your gametype in there, in some  shape or form. <br>
               <br>
              You’ll also be pleased to hear that split-screen will be an option,  although limited to two people in the Public Beta. We’ve also done  something cool with the splitscreen display for HD monitors – instead  of stretching the horizontal or vertical axes into big, scary too wide  or too tall horrors, we’ve sensibly windowed the action, maintaining  lots of screen real estate, but preserving a proper, playable aspect  ratio. <br>
              Jub-Jub, (codename for one of the secret Multiplayer maps) is coming  along beautifully. Steve Cotton has been decorating it with…well, that  would probably give away the theme. But I will mention that right now  it has birds in it, flying around in a convincingly flock-like fashion,  but don’t get too used to that idea. If there was ever something  superfluous to gameplay, it would be a flock of birds wheeling around  in the far distance. If it so much as twitches, it gets cut.<br>
              Perhaps more enticing is the mention of a VERY large map that went  from being just about the most empty, soulless placeholder geometry in  the entire game, to one of the moodiest, most atmospheric and beautiful  maps we’ve ever made. It’s also the single largest multiplayer map. You  pretty much need a vehicle to get around in it, so luckily, destroyed  vehicles respawn super-fast.<br>
              We’re very excited to show off the second part of our Halo 3 image  branding. This one is known colloquially as “Emotion” and it’s just a  lovely, stirring piece that speaks to both the fiction and the  atmosphere of the new game. The more you look at it, the more you get  from it. The Chief model was built and posed from the game, and  rendered out in this mixed media piece, which is part CG, part painting  and a healthy dose of Photoshop thrown in for good measure. The  background holds some interesting atmosphere, from the skeletal  wreckage of the fallen Mombasa space tether, to those hauntingly  familiar eyes in the background. Anyway, that’s enough talk – here’s a  pic. This one will be appearing soon enough, in various locations in  both landscape and portrait orientations.<br />
                  <br />
              <br>
              <p align="center"> <a href="http://www.bungie.net/images/Games/Halo3/Wallpapers/H3_Emotion-H_Landscape.jpg" target="_blank"> <img src="http://www.bungie.net/images/News/InlineImages2007/H3_EmotionLandscape.jpg" border="0" /> </a> <br />
                Click through for the hugeness, or check out both the portrait and landscapes in our updated Wallpaper section.<br>
               <strong> <br />
                RUMOR BUSTER</strong> <br>
              I read a bunch of random rumors this week and since they had bunched  up, I feared that they would clog the series of pipes comprising the  Internet. The last thing I want is for the Internet to back up and  spill foul smelling data into your living room, so I will do some  Roto-rooting of my own. <br>
              May 11th was mentioned in a San Jose Mercury News blog as  an “unveiling” date for Halo 3. Of course Halo 3 was in fact “unveiled”  at E3 a year ago. The May 11th date simply refers to a  Public Beta preview for the press so they can get their stories done  for the real Public Beta launch a few days later.<br />
              <br>
               <br>
               <br />
              <br>
              Wired Magazine’s editor in chief, Chris Anderson, revealed in his  blog a couple of pages of script dialog that he’d recorded. Interweb  sleuths thought they’d discovered some plot points. Sad to say that  other than the dialog itself and the names of the characters on those  script pages, just about everything else is a red herring. So don’t  read too much into it.<br>
              Then there was the “secret email from the Argo” which folks had  mistaken for some sort of Bungie or Halo 3 viral campaign, or ARG. I  don’t know what it really is, beyond fan-fic, but it’s not from us.  These ARG rumors are going to get really common between now and the  fall, so by all means enjoy them, but don’t assume they have anything  to do with Bungie or Halo 3.<br>
              The strangest rumor of all was that MS was “forcing” Bungie to make  Halo 3 60 fps at 1080p. Um, it was one thing to see that on a forum,  but it was strange to see it on regular news site. <br>
              1080p at 60 fps is awesome for fighting games and barely a stretch  for Live Arcade games. But if you want epic battles, dozens of bad  guys, huge vistas and colossal structures, with advanced AI, HDR  lighting and explosive physics, then you’re not getting those at 1080p  at 60fps. Actually, that’s not entirely accurate – Halo 3 <em>will</em> display at 1080p through the Xbox Elite with its scaler and HDMI port, but not <em>natively</em>.  We’ve seen it do just that and it looks utterly lovely. So if you have  a 1080p TV, enjoy it yourself in a few weeks. Most people, and I mean  the VAST majority of people don’t have a 1080p TV, so it would be  foolish to sacrifice even a single feature for a bullet point number on  the back of a box.<br>
              The only number we’re committing to is that our <em>number</em> <em>one</em> priority is to make Halo 3 look awesome, smooth, detailed and  innovative, no matter what resolution you run it at. Although that  said, it does look significantly better in HD, so maybe you should  convince the powers that be, that now is the time for a set upgrade?<br>
              Actually, HD resolutions are one of the tougher things to account  for when building a console game. PC game makers are used to supporting  multiple resolutions and we do have lots of experience in this regard.  But when you add it to the test cycle, it becomes this enormous amount  of work. Every aspect of the game has to be tested at 480i (normal,  ancient TV resolution) all the way up to 1080p resolutions to check for  everything from graphical glitches to controller lag. And the odd thing  about HD resolutions is that they aren’t even necessarily “correct” to  begin with.<br>
               <br>
              For example, most folks running an image at 720p, are doing so on a  screen with a native resolution of 1280 X 768. The HD resolutions were  all decided on during the heyday of the CRT tube, so the introduction  of fixed pixel displays brought along with it new problems and  inconsistencies. We have to build graphics and gameplay to work with  everything from that ancient wooden RCA in the basement to a 60 inch  Pioneer Elite. I think that one of the real payoffs of all this testing  is that it looks pretty damned good and “next-gen” even on a cruddy old  set. I actually know someone who uses a 360 via a crazy RF adapter. Now  that <em>is </em>hardcore!<br>
              I’m in the midst of redoing my gaming rig at home, and now that I  have my 5.1 sound system just the way I want it, I actually found  myself using Halo 3 to adjust the settings. This part is embarrassing,  but folks who’ve moved their setups around might be able to relate – I  unplugged all the speaker wires, and in the transition lost track of  which rear surround was left and which was right. I loaded up the Halo  3 Beta and tossed around a couple of grenades. I had in fact switched  the wires by accident. Dur. Thank you grenades.<br>
               <strong> CONTROL SCHEMER </strong> <br>
              Last week’s Humpday Challenge brought with it another challenge.  Quickly getting used to Halo 2 controls after months of playing Halo 3.  I thought I would take a moment or two today to run you through the <em>Beta</em> control scheme (it will certainly change or improve between now and  launch, after all) and so below, you’ll see a diagram of the current <em>default </em>scheme.  Don’t worry, the Beta will include all the standard setups that you’re  used to. And this diagram does not include some of the functions  available from the <em>Start </em>and <em>Back </em>buttons, since they require a quick dig-down into the interface.<br />
              <br>
               <br>
               <br>
              <p align="center"> <img src="http://www.bungie.net/images/News/InlineImages2007/Controller_Halo3.jpg" /> <br />
                This layout is subject to change, but will give you an idea of what to expect.<br />
              <br>
               <br />
                Now, the single hardest thing to get used to, by far, is using <em>RB </em>to  board vehicles, open doors and so on. It also reloads depleted weapons.  That may sound like a lot of functions, but it isn’t really, since it’s  contextual – you won’t reload instead of opening a gate, for example.  Once you get used to RB – everything else is a breeze and pretty  intuitive. Independent reloading of weapons is a <em>blessing</em> when you’re dual-wielding. It means you can fire one, while reloading the other.<br>
              The X-button is second nature. You’ll know when you’re carrying  equipment – it’ll appear in your HUD, and all you do to use it is press  X. On that note, I saw another meme pop up, and not an unreasonable one  at that: You might be able to drop a shield on a vehicle and then drive  around shielded. Well, nope. Cool as that might look, it would probably  make a vehicle way too powerful. You should try playing around with  what you can and can’t do with shields (and whatever else you find) in  the Beta. It’s a blast.<br>
               <br>
              One other advantage to the X-Button/RB switcheroo is that a thing  that happened to me last week will be avoided – accidental ejection for  betrayal. Everyone heads for an Oddball with X held down, tossing  grenades at the bad guys, so when an accidental betrayal happens,  everyone is mashing “X to eject” the entire time.<br>
               <br>
              Xbox.com’s very own TriXie was the hostess with the mostest at last  week’s Halo 2 All Nighter – an event to enjoy and celebrate the new  Halo 2 map downloads. You can read about some of the antics and  community reactions here: <a href="http://www.xbox.com/en-US/games/friendsofxbox/gamerspeak/2007/0427-halo2allnighter.htm">http://www.xbox.com/en-US/games/friendsofxbox/gamerspeak/2007/0427-halo2allnighter.htm</a><br>
               <br>
              And finally, you'd think I wouldn't go there, but I totally did. I regret nothing.<br />
                  <br />
              <br>
              <p align="center"> <img src="http://www.bungie.net/images/News/InlineImages2007/misteridiot.jpg" /> <br>
            
          
          <ul id="ctl00_mainContent_forumLinkContainer">
            <li><a href="http://www.bungie.net/Forums/posts.aspx?postID=10648074">Discuss this story</a></li>
          </ul>
          <hr />
          <ul>
            <li><a href="http://www.bungie.net/News/archive.aspx?mode=topnews">View Top Story Archive</a></li>
          </ul>

That is the data that I am inserting.

echoing it shows exactly the same.

I have the following on my index.php file (the page that I get the data on):

<img src="<?php echo $image_path; ?>" alt="<?php echo $news_title; ?>" />
			<?php 
			$content = html_entity_decode(stripslashes($content));
			echo filter_charlimit(strip_tags($news_content,'<br>'),100,'...<a href="morenews.php?morenews='.$news_id.'">More Info</a>'); ?>

 

On the insert into the db page i have:

$_FILES['file']['name'] = md5(rand()) . $_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'],"/***/".$_FILES['file']['name']);
$title = $_POST['title'];
$content = htmlspecialchars($_POST['news'], ENT_QUOTES);
$author = $_POST['author'];
$date = date("Y-m-d H:i:s");
$image_path = "/***/".$_FILES['file']['name'];
$insert_news = mysql_query("insert into news (news_title,news_content,news_author,date,image_path) values ('{$title}','{$content}','{$author}','{$date}','{$image_path}')",$conn);

 

Edit:

Im rather stupid. I didnt call the variables the correct names lol

It works now. Thanks for your help!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.