Daily Archives

Articles indexed Monday October 22 2012

Page 10/16 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Installing an asp application on a dnn server

    - by Cody Henrichsen
    I created a registration db/web application in C# for some workshops. The organization requesting is hosted on a DotNetNuke server. What changes do I need to make to the web.config so it can run under the site. Currently when I try to go to a page it get an error: Server Error in '/' Application. Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

    Read the article

  • Snake Game Help

    - by MuhammadA
    I am making a snake game and learning XNA at the same time. I have 3 classes : Game.cs, Snake.cs and Apple.cs My problem is more of a conceptual problem, I want to know which class is really responsible for ... detecting collision of snake head on apple/itself/wall? which class should increase the snakes speed, size? It seems to me that however much I try and put the snake stuff into snake.cs that game.cs has to know a lot about the snake, like : -- I want to increase the score depending on size of snake, the score variable is inside game.cs, which means now I have to ask the snake its size on every hit of the apple... seems a bit unclean all this highly coupled code. or -- I DO NOT want to place the apple under the snake... now the apple suddenly has to know about all the snake parts, my head hurts when I think of that. Maybe there should be some sort of AppleLayer.cs class that should know about the snake... Whats the best approach in such a simple scenario? Any tips welcome. Game.cs : using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; using Microsoft.Xna.Framework.Design; namespace Snakez { public enum CurrentGameState { Playing, Paused, NotPlaying } public class Game1 : Microsoft.Xna.Framework.Game { private GraphicsDeviceManager _graphics; private SpriteBatch _spriteBatch; private readonly Color _niceGreenColour = new Color(167, 255, 124); private KeyboardState _oldKeyboardState; private SpriteFont _scoreFont; private SoundEffect _biteSound, _crashSound; private Vector2 _scoreLocation = new Vector2(10, 10); private Apple _apple; private Snake _snake; private int _score = 0; private int _speed = 1; public Game1() { _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } /// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { base.Initialize(); } /// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); _scoreFont = Content.Load<SpriteFont>("Score"); _apple = new Apple(800, 480, Content.Load<Texture2D>("Apple")); _snake = new Snake(Content.Load<Texture2D>("BodyBlock")); _biteSound = Content.Load<SoundEffect>("Bite"); _crashSound = Content.Load<SoundEffect>("Crash"); } /// <summary> /// UnloadContent will be called once per game and is the place to unload /// all content. /// </summary> protected override void UnloadContent() { Content.Unload(); } /// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { KeyboardState newKeyboardState = Keyboard.GetState(); if (newKeyboardState.IsKeyDown(Keys.Escape)) { this.Exit(); // Allows the game to exit } else if (newKeyboardState.IsKeyDown(Keys.Up) && !_oldKeyboardState.IsKeyDown(Keys.Up)) { _snake.SetDirection(Direction.Up); } else if (newKeyboardState.IsKeyDown(Keys.Down) && !_oldKeyboardState.IsKeyDown(Keys.Down)) { _snake.SetDirection(Direction.Down); } else if (newKeyboardState.IsKeyDown(Keys.Left) && !_oldKeyboardState.IsKeyDown(Keys.Left)) { _snake.SetDirection(Direction.Left); } else if (newKeyboardState.IsKeyDown(Keys.Right) && !_oldKeyboardState.IsKeyDown(Keys.Right)) { _snake.SetDirection(Direction.Right); } _oldKeyboardState = newKeyboardState; _snake.Update(); if (_snake.IsEating(_apple)) { _biteSound.Play(); _score += 10; _apple.Place(); } base.Update(gameTime); } /// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(_niceGreenColour); float frameRate = 1 / (float)gameTime.ElapsedGameTime.TotalSeconds; _spriteBatch.Begin(); _spriteBatch.DrawString(_scoreFont, "Score : " + _score, _scoreLocation, Color.Red); _apple.Draw(_spriteBatch); _snake.Draw(_spriteBatch); _spriteBatch.End(); base.Draw(gameTime); } } } Snake.cs : using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; namespace Snakez { public enum Direction { Up, Down, Left, Right } public class Snake { private List<Rectangle> _parts; private readonly Texture2D _bodyBlock; private readonly int _startX = 160; private readonly int _startY = 120; private int _moveDelay = 100; private DateTime _lastUpdatedAt; private Direction _direction; private Rectangle _lastTail; public Snake(Texture2D bodyBlock) { _bodyBlock = bodyBlock; _parts = new List<Rectangle>(); _parts.Add(new Rectangle(_startX, _startY, _bodyBlock.Width, _bodyBlock.Height)); _parts.Add(new Rectangle(_startX + bodyBlock.Width, _startY, _bodyBlock.Width, _bodyBlock.Height)); _parts.Add(new Rectangle(_startX + (bodyBlock.Width) * 2, _startY, _bodyBlock.Width, _bodyBlock.Height)); _parts.Add(new Rectangle(_startX + (bodyBlock.Width) * 3, _startY, _bodyBlock.Width, _bodyBlock.Height)); _direction = Direction.Right; _lastUpdatedAt = DateTime.Now; } public void Draw(SpriteBatch spriteBatch) { foreach (var p in _parts) { spriteBatch.Draw(_bodyBlock, new Vector2(p.X, p.Y), Color.White); } } public void Update() { if (DateTime.Now.Subtract(_lastUpdatedAt).TotalMilliseconds > _moveDelay) { //DateTime.Now.Ticks _lastTail = _parts.First(); _parts.Remove(_lastTail); /* add new head in right direction */ var lastHead = _parts.Last(); var newHead = new Rectangle(0, 0, _bodyBlock.Width, _bodyBlock.Height); switch (_direction) { case Direction.Up: newHead.X = lastHead.X; newHead.Y = lastHead.Y - _bodyBlock.Width; break; case Direction.Down: newHead.X = lastHead.X; newHead.Y = lastHead.Y + _bodyBlock.Width; break; case Direction.Left: newHead.X = lastHead.X - _bodyBlock.Width; newHead.Y = lastHead.Y; break; case Direction.Right: newHead.X = lastHead.X + _bodyBlock.Width; newHead.Y = lastHead.Y; break; } _parts.Add(newHead); _lastUpdatedAt = DateTime.Now; } } public void SetDirection(Direction newDirection) { if (_direction == Direction.Up && newDirection == Direction.Down) { return; } else if (_direction == Direction.Down && newDirection == Direction.Up) { return; } else if (_direction == Direction.Left && newDirection == Direction.Right) { return; } else if (_direction == Direction.Right && newDirection == Direction.Left) { return; } _direction = newDirection; } public bool IsEating(Apple apple) { if (_parts.Last().Intersects(apple.Location)) { GrowBiggerAndFaster(); return true; } return false; } private void GrowBiggerAndFaster() { _parts.Insert(0, _lastTail); _moveDelay -= (_moveDelay / 100)*2; } } } Apple.cs : using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; namespace Snakez { public class Apple { private readonly int _maxWidth, _maxHeight; private readonly Texture2D _texture; private readonly Random random = new Random(); public Rectangle Location { get; private set; } public Apple(int screenWidth, int screenHeight, Texture2D texture) { _maxWidth = (screenWidth + 1) - texture.Width; _maxHeight = (screenHeight + 1) - texture.Height; _texture = texture; Place(); } public void Place() { Location = GetRandomLocation(_maxWidth, _maxHeight); } private Rectangle GetRandomLocation(int maxWidth, int maxHeight) { // x and y -- multiple of 20 int x = random.Next(1, maxWidth); var leftOver = x % 20; x = x - leftOver; int y = random.Next(1, maxHeight); leftOver = y % 20; y = y - leftOver; return new Rectangle(x, y, _texture.Width, _texture.Height); } public void Draw(SpriteBatch spriteBatch) { spriteBatch.Draw(_texture, Location, Color.White); } } }

    Read the article

  • Maya is lagging in a specific way...?

    - by Aerovistae
    My Maya installation worked perfectly. It is not my computer. Something caused it to stop working overnight, somehow. When I try to drag a vertex or something like that, it moves the vertex, but then I have to click like 3 times somewhere outside the mesh before the actual mesh will catch up and follow the vertex. Until I do that, it just stays as it was, with a floating vertex somewhere inside it or outside it. It makes modeling borderline impossible and completely infuriating. What ought to be happening is what we're all used to-- as I move the vertex, the mesh follows it actively, so I can see what it looks like at every given moment until I release the vertex in its new position. Other weird thing: this only applies to complex meshes, like a couple thousand faces. A simple cube works fine. What gives?? Anybody?

    Read the article

  • Inline in aspx, stripping date off of datetime

    - by DJGray
    I think if I just show you the following what I'm asking will make sense. In a link in my aspx, this works: ' title='<%# Container.DataItem["EventTime"].ToString() But the above contains the date portion of the string. This does not work (nor does any variant of it): ' title='<%# Container.DataItem["EventTime"].ToString("hh:mm:ss tt", CultureInfo.InvariantCulture) % Evantually, we want the title/hover for the link to read something like "4:30 PM : @Forbes Field" Everything is working with the exception of the 1/1/1900 being in front of the 4:30 How do I get the date off that EventTime datetime field?

    Read the article

  • how should i load a bitmap for an android game?

    - by Heysus Escobar
    i been working on a game with no bitmaps or anything, I'm using rectangles as objects and changing their color for their purpose like a red rectangles for player and gray rectangles for walls. My question is what is the right way to replace the rectangles with bitmaps/images? I know to load Bitmaps you can just do this : Bitmap randomBitmap = BitmapFactory.decodeResource(getResources(), com.example.android4gametest.R.drawable.ic_launcher); Should i load all my Bitmaps and pass them to their Classes or should i load the bitmap inside their class instead of passing it ? and how would i do that because i cannot use the BitmapFactory because i have no access to the getResources()! or should i load my bitmaps/images from my assets folder which i know i wont have the same "tools" you can say to mess with the bitmap.

    Read the article

  • JavaScript - Multiple signals received after click

    - by Angelo A
    I'm creating a webapp using jQueryMobile. When I'm using the app and I click a button it runs the script multiple times. For example: I have a submit button: <input type="submit" id="login-normal" value="Login" /> And I have this JavaScript for debugging on which this error occurs: $("input#login-normal").live('click',function() { console.log("Test"); }); On the very first click it works (and it goes to another screen for example), but when I go back to that screen and I click again, it outputs multiple console.logs

    Read the article

  • populating an nsarray

    - by MoKaM
    I intend to make a program that does the following: Create an NSArray populated with numbers from 1 to 100,000. Loop over some code that deletes certain elements of the NSArray when certain conditions are met. Store the resultant NSArray. However the above steps will also be looped over many times and so I need a fast way of making this NSArray that has 100,000 number elements. So what is the fastest way of doing it? Is there an alternative to iteratively populating an Array using a for loop? Such as an NSArray method that could do this quickly for me? Or perhaps I could make the NSArray with the 100,000 numbers by any means the first time. And then create every new NSArray (for step 1) by using method arraywithArray? (is it quicker way of doing it?) Or perhaps you have something completely different in mind that will achieve what I want. edit: Replace NSArray with NSMutableArray in this post.

    Read the article

  • c++ program debugged well with Cygwin4 (under Netbeans 7.2) but not with MinGW (under QT 4.8.1)

    - by GoldenAxe
    I have a c++ program which take a map text file and output it to a graph data structure I have made, I am using QT as I needed cross-platform program and GUI as well as visual representation of the map. I have several maps in different sizes (8x8 to 4096x4096). I am using unordered_map with a vector as key and vertex as value, I'm sending hash(1) and equal functions which I wrote to the unordered_map in creation. Under QT I am debugging my program with QT 4.8.1 for desktop MinGW (QT SDK), the program works and debug well until I try the largest map of 4096x4096, then the program stuck with the following error: "the inferior stopped because it received a signal from operating system", when debugging, the program halt at the hash function which used inside the unordered_map and not as part of the insertion state, but at a getter(2). Under Netbeans IDE 7.2 and Cygwin4 all works fine (debug and run). some code info: typedef std::vector<double> coordinate; typedef std::unordered_map<coordinate const*, Vertex<Element>*, container_hash, container_equal> vertexsContainer; vertexsContainer *m_vertexes (1) hash function: struct container_hash { size_t operator()(coordinate const *cord) const { size_t sum = 0; std::ostringstream ss; for ( auto it = cord->begin() ; it != cord->end() ; ++it ) { ss << *it; } sum = std::hash<std::string>()(ss.str()); return sum; } }; (2) the getter: template <class Element> Vertex<Element> *Graph<Element>::getVertex(const coordinate &cord) { try { Vertex<Element> *v = m_vertexes->at(&cord); return v; } catch (std::exception& e) { return NULL; } } I was thinking maybe it was some memory issue at the beginning, so before I was thinking of trying Netbeans I checked it with QT on my friend pc with a 16GB RAM and got the same error. Thanks.

    Read the article

  • ggplot2 add legend for each geom_point manually

    - by user1162769
    I created a plot using 2 separate data sets so that I could create different errorbars. The first data set has error bars that go down only whereas the second data set has error bars that go up only. This prevents unnecessary overlap in the plot. I also used a compound shape for one of the groups. I want to create a legend based on these shapes (not a colour), but I can't seem to figure it out. Here is the plot code. p<-ggplot() p + geom_point(data=df.figure.1a, aes(x=Hour, y=Mean), shape=5, size=4) + geom_point(data=df.figure.1a, aes(x=Hour, y=Mean), shape=18, size=3) + geom_errorbar(data=df.figure.1a, aes(x=Hour, y=Mean, ymin = Mean - SD, ymax = Mean), size=0.7, width = 0.4) + geom_point(data=df.figure.1b, aes(x=Hour, y=Mean), shape=17, size=4) + geom_errorbar(data=df.figure.1b, aes(x=Hour, y=Mean, ymin = Mean, ymax = Mean + SD), size=0.7, width = 0.4)

    Read the article

  • im i doing this right or wrong using pointers in C

    - by Amandeep Singh Dhari
    i like to point out that i need some help with my home work, ok the lectuer gave us the idea of a program and we have to make it from bottom to top. got to have user to type in two set of string. pointers take in the value and then puts into a prototype i need to make a 3rd pointer that has the value of p1 and p2. like this p1 = asd, p2 = qwe and p3 = asdqwe #include "stdafx.h" #include <ctype.h> char *mystrcat(char*s1p, char*s2p); // Prototype char main(void) { char string1[80]; char string2[80]; printf("%s", "enter in your srting one "); gets_s(string1); printf("%s", "enter in your srting two "); gets_s(string2); *mystrcat(string1, string2); return 0; } char *mystrcat(char *s1p,char *s2p) { //char *string3; //char *string4; //string3 = s1p; //string4 = s2p; printf("whatever = %s%s\n", s1p, s2p); return 0; } this is the code that i made so far just need some help, thank guys in advance.

    Read the article

  • How do you display a PHPmyadmin table onto a web browser/web page?

    - by user1390754
    Just a simple question, i've been searching around and for some reason i cannot find an answer to this. after creating a database/table in Phpmyadmin using xampp, what command do i need to put into my webpage (PHP) to show the table I made? I know the first step involves connecting to the database and i think i've done that properly. This is the code i found from somewhere about connecting (w3 tutorials I believe) $con = mysql_connect("localhost","xxxxxx,""); if (!$con) { die('Could not connect: ' . mysql_error()); }

    Read the article

  • Centering form elements with left alignment

    - by user1766797
    I would like to center the elements in my form without moving the text or buttons from being aligned on the left. So it would look like this: The bottom square is supposed to be a button. I want it centered, but the <center> tag moves the text and button so they're centered to the input box. Here is my code: <form action="login.php" method="post"> <div class="aside"> <div id="center"> Username:<br> <input type="text" name="username"><br> Password:<br> <input type="password" name="passwor"><br> <input type="submit" class="button" name="submit" value="Login"><br><br> </div> </div> </form> and the css: #center{ width: 250px; margin-left: auto; margin-right: auto; float: center; } div.aside { margin-left: 15px; margin-top: 10px; width: 250px; background: #f5f5f5; border: 1px solid #e9e9e9; line-height: 150%; } div.aside .button{ padding:3px; width: 50px; margin-top: 3px; background-color: #00A1E6; border: 1px solid #0184BC; text-decoration:none; color: #ffffff; text-align: center; -webkit-appearance: none; }

    Read the article

  • Scalable way to store files on server (PHP)?

    - by Nathaniel Bennett
    I'm creating my first web application - a really simplistic online text editor. What I need to do is find the best way to store text based files - a lot of them. These text files can be past 10,000 words in size (text words not computer words.) in essence I want the text documents to be limitless in size. I was thinking about storing the text files in my MySQL database - but thought there was a better way. Instead I'm planing on storing the text files in XML based format in a directory on my server. The rows in the database define the name of the xml based text file and the user who created the text along with basic metadata. An ID is generated using a V4 GUID generator , which gives the text an id and stores the text in the "/store" directory on my server. The text definitions in my server contain this id, and the android app I'm developing gets the contents of the text file by retrieving the text definition and then downloading the text to the local device using the GUID in the text definition. I just think this is a botch job? how can I improve this system? There has been cases of GUID colliding. I don't want this to happen. A "slim" possibility isn't good enough - I need to make sure there is absolutely no chance in a GUID collision. I was planning on checking the database for texts that have the same id before storing the text with a particular id - I however believe with over 20,000 pieces of text in my database this would take an long time and produce unneeded stress on the server. How can I make GUID safe? What happens when a GUID collides? The server backend is going to be written in PHP.

    Read the article

  • ASP.NET MVC3 ValueProvider drops string input to a double property

    - by Daniel Koverman
    I'm attempting to validate the input of a text box which corresponds to a property of type double in my model. If the user inputs "foo" I want to know about it so I can display an error. However, the ValueProvider is dropping the value silently (no errors are added to the ModelState). In a normal submission, I fill in "2" for the text box corresponding to myDouble and submit the form. Inspecting controllerContext.HttpContext.Request.Form shows that myDouble=2, among other correct inputs. bindingContext.ValueProvider.GetValue("myDouble") == 2, as expected. The bindingContext.ModelState.Count == 6 and bindingContext.ModelState["myDouble"].Errors.Count == 0. Everything is good and the model binds as expected. Then I fill in "foo" for the text box corresponding to myDouble and submitted the form. Inspecting controllerContext.HttpContext.Request.Form shows that myDouble=foo, which is what I expected. However, bindingContext.ValueProvider.GetValue("myDouble") == null and bindingContext.ModelState.Count == 5 (The exact number isn't important, but it's one less than before). Looking at the ValueProvider, is as if myDouble was never submitted and the model binding occurs as if it wasn't. This makes it difficult to differentiate between a bad input and no input. Is this the expected behavior of ValueProvider? Is there a way to get ValueProvider to report when conversion fails without implementing a custom ValueProvider? Thanks!

    Read the article

  • select nodes from a line of xml code with sql

    - by wondergoat77
    I have a table that stores a huge line/entire document of xml like this: <?xml version="1.0" encoding="utf-16"?> <RealQuestResponse xmlns:xsi="http://www.w3.org /2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Success>true</Success> <Subject> <AmbiguousMatches /> <Assessment> <LandValue>0</LandValue> <ImprovementsValue>0</ImprovementsValue> <TotalValue>0</TotalValue> </Assessment> <RecentSales /> <Warnings> <Score>0</Score> <TrusteesDeedRatio>0</Tr........etc Is there a way to pull any of these fields out of the xml? it is stored in a column in a table called AutomatedRequests That table looks like this: requestid Provider Date Success Response 1 test 1/2/2012 Y <?xml version..... <---this is the xml code stored> Ive seen a couple ways but nothing like this Id basically like something like select xmlnode1, xmlnode2, xmlnode3 from automatedrequests have tried this but not working: select xml.query('RealQuestResponse/Bedrooms/*') from automatedRequests where orderid = 1266162

    Read the article

  • files get uploaded just before they get cancelled

    - by user1763986
    Got a little situation here where I am trying to cancel a file's upload. What I have done is stated that if the user clicks on the "Cancel" button, then it will simply remove the iframe so that it does not go to the page where it uploads the files into the server and inserts data into the database. Now this works fine if the user clicks on the "Cancel" button in quickish time the problem I have realised though is that if the user clicks on the "Cancel" button very late, it sometimes doesn't remove the iframe in time meaning that the file has just been uploaded just before the user has clicked on the "Cancel" button. So my question is that is there a way that if the file does somehow get uploaded before the user clicks on the "Cancel" button, that it deletes the data in the database and removes the file from the server? Below is the image upload form: <form action="imageupload.php" method="post" enctype="multipart/form-data" target="upload_target_image" onsubmit="return imageClickHandler(this);" class="imageuploadform" > <p class="imagef1_upload_process" align="center"> Loading...<br/> <img src="Images/loader.gif" /> </p> <p class="imagef1_upload_form" align="center"> <br/> <span class="imagemsg"></span> <label>Image File: <input name="fileImage" type="file" class="fileImage" /></label><br/> <br/> <label class="imagelbl"><input type="submit" name="submitImageBtn" class="sbtnimage" value="Upload" /></label> </p> <p class="imagef1_cancel" align="center"> <input type="reset" name="imageCancel" class="imageCancel" value="Cancel" /> </p> <iframe class="upload_target_image" name="upload_target_image" src="#" style="width:0px;height:0px;border:0px;solid;#fff;"></iframe> </form> Below is the jquery function which controls the "Cancel" button: $(imageuploadform).find(".imageCancel").on("click", function(event) { $('.upload_target_image').get(0).contentwindow $("iframe[name='upload_target_image']").attr("src", "javascript:'<html></html>'"); return stopImageUpload(2); }); Below is the php code where it uploads the files and inserts the data into the database. The form above posts to this php page "imageupload.php": <body> <?php include('connect.php'); session_start(); $result = 0; //uploads file move_uploaded_file($_FILES["fileImage"]["tmp_name"], "ImageFiles/" . $_FILES["fileImage"]["name"]); $result = 1; //set up the INSERT SQL query command to insert the name of the image file into the "Image" Table $imagesql = "INSERT INTO Image (ImageFile) VALUES (?)"; //prepare the above SQL statement if (!$insert = $mysqli->prepare($imagesql)) { // Handle errors with prepare operation here } //bind the parameters (these are the values that will be inserted) $insert->bind_param("s",$img); //Assign the variable of the name of the file uploaded $img = 'ImageFiles/'.$_FILES['fileImage']['name']; //execute INSERT query $insert->execute(); if ($insert->errno) { // Handle query error here } //close INSERT query $insert->close(); //Retrieve the ImageId of the last uploded file $lastID = $mysqli->insert_id; //Insert into Image_Question Table (be using last retrieved Image id in order to do this) $imagequestionsql = "INSERT INTO Image_Question (ImageId, SessionId, QuestionId) VALUES (?, ?, ?)"; //prepare the above SQL statement if (!$insertimagequestion = $mysqli->prepare($imagequestionsql)) { // Handle errors with prepare operation here echo "Prepare statement err imagequestion"; } //Retrieve the question number $qnum = (int)$_POST['numimage']; //bind the parameters (these are the values that will be inserted) $insertimagequestion->bind_param("isi",$lastID, 'Exam', $qnum); //execute INSERT query $insertimagequestion->execute(); if ($insertimagequestion->errno) { // Handle query error here } //close INSERT query $insertimagequestion->close(); ?> <!--Javascript which will output the message depending on the status of the upload (successful, failed or cancelled)--> <script> window.top.stopImageUpload(<?php echo $result; ?>, '<?php echo $_FILES['fileImage']['name'] ?>'); </script> </body> UPDATE: Below is the php code "cancelimage.php" where I want to delete the cancelled file from the server and delete the record from the database. It is set up but not finished, can somebody finish it off so I can retrieve the name of the file and it's id using $_SESSION? <?php // connect to the database include('connect.php'); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); die(); } //remove file from server unlink("ImageFiles/...."); //need to retrieve file name here where the ... line is //DELETE query statement where it will delete cancelled file from both Image and Image Question Table $imagedeletesql = " DELETE img, img_q FROM Image AS img LEFT JOIN Image_Question AS img_q ON img_q.ImageId = img.ImageId WHERE img.ImageFile = ?"; //prepare delete query if (!$delete = $mysqli->prepare($imagedeletesql)) { // Handle errors with prepare operation here } //Dont pass data directly to bind_param store it in a variable $delete->bind_param("s",$img); //execute DELETE query $delete->execute(); if ($delete->errno) { // Handle query error here } //close query $delete->close(); ?> Can you please provide an sample code in your answer to make it easier for me. Thank you

    Read the article

  • I am getting duplicates in UITableView, cellForRowAtIndexPath

    - by Martol1ni
    I am getting duplicates of my array, and wrongly displayed cells in this method: Here I am initializing the array, and adding it to the tableView: NSArray *sectionsArray = [NSArray arrayWithObjects: @"Location", @"Front Post", @"Front Fixing", @"Front Footplate", @"Rear Post", @"Read Fixing", @"Rear Footplate", @"Horizontal Bracing", @"Diagonal Bracing", @"Front Beam", @"Front Lock", @"Rear Beam", @"Rear Lock", @"Guard", @"Accessories", @"Comments", @"Off load ref", @"Loc Empty", @"Loc Affected", nil]; [_tableArray setObject:sectionsArray atIndexedSubscript:2]; [_tableView reloadData]; For some weird reason there are always the 4th object that is messed up, and is either duplicated, or do not have the views from IB. Here is the cellForRowAtIndexPath: method: - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell; if (indexPath.section == 2) { cell = [tableView dequeueReusableCellWithIdentifier:@"EntryCell"]; cell.tag = indexPath.row; UILabel *label = (UILabel *)[cell viewWithTag:3]; [label setText:[[_tableArray objectAtIndex:2] objectAtIndex:indexPath.row]]; } return cell; } I have logged the string [[_tableArray objectAtIndex:2] objectAtIndex:indexPath.row], and it logs the right string.

    Read the article

  • Receiving "expected expression before" Error When Using A Struct

    - by Zach Dziura
    I'm in the process of creating a simple 2D game engine in C with a group of friends at school. I'd like to write this engine in an Object-Oriented way, using structs as classes, function pointers as methods, etc. To emulate standard OOP syntax, I created a create() function which allocates space in memory for the object. I'm in the process of testing it out, and I'm receiving an error. Here is my code for two files that I'm using to test: test.c: #include <stdio.h> int main() { typedef struct { int i; } Class; Class *test = (Class*) create(Class); test->i = 1; printf("The value of \"test\" is: %i\n", test->i); return 0; } utils.c: #include <stdio.h> #include <stdlib.h> #include "utils.h" void* create(const void* class) { void *obj = (void*) malloc(sizeof(class)); if (obj == 0) { printf("Error allocating memory.\n"); return (int*) -1; } else { return obj; } } void destroy(void* object) { free(object); } The utils.h file simply holds prototypes for the create() and destroy() functions. When I execute gcc test.c utils.c -o test, I'm receiving this error message: test.c: In function 'main': test.c:10:32: error: expected expression before 'Class' I know it has something to do with my typedef at the beginning, and how I'm probably not using proper syntax. But I have no idea what that proper syntax is. Can anyone help?

    Read the article

  • Azure Blobs - ArgumentNullException when calling UploadFile()

    - by Ariel
    I’m getting the following exception when trying to upload a file with the following code: string encodedUrl = "videos/Sample.mp4" CloudBlockBlob encodedVideoBlob = blobClient.GetBlockBlobReference(encodedUrl); Log(string.Format("Got blob reference for {0}", encodedUrl), EventLogEntryType.Information); encodedVideoBlob.Properties.ContentType = contentType; encodedVideoBlob.Metadata[BlobProperty.Description] = description; encodedVideoBlob.UploadFile(localEncodedBlobPath); I see the "Got blob reference" message, so I assume the reference resolves correctly. Void Run() C:\Inter\Projects\PoC\WorkerRole\WorkerRole.cs (40) System.ArgumentNullException: Value cannot be null. Parameter name: value at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result() at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait() at Microsoft.WindowsAzure.StorageClient.CloudBlob.UploadFromStream(Stream source, BlobRequestOptions options) at Microsoft.WindowsAzure.StorageClient.CloudBlob.UploadFile(String fileName, BlobRequestOptions options) at EncoderWorkerRole.WorkerRole.ProcessJobOutput(IJob job, String videoBlobToEncodeUrl) in C:\Inter\Projects\PoC\WorkerRole\WorkerRole.cs:line 144 at EncoderWorkerRole.WorkerRole.Run() in C:\Inter\Projects\PoC\WorkerRole\WorkerRole.cs:line 40 Interestingly, I'm running that same snippet from an on-premises server i.e., outside of Azure and it works correctly. Ideas welcome, thanks!

    Read the article

  • why doesnt this program print?

    - by Alex
    What I'm trying to do is to print my two-dimensional array but i'm lost. The first function is running perfect, the problem is the second or maybe the way I'm passing it to the "Print" function. #include <stdio.h> #include <stdlib.h> #define ROW 2 #define COL 2 //Memory allocation and values input void func(int **arr) { int i, j; arr = (int**)calloc(ROW,sizeof(int*)); for(i=0; i < ROW; i++) arr[i] = (int*)calloc(COL,sizeof(int)); printf("Input: \n"); for(i=0; i<ROW; i++) for(j=0; j<COL; j++) scanf_s("%d", &arr[i][j]); } //This is where the problem begins or maybe it's in the main void print(int **arr) { int i, j; for(i=0; i<ROW; i++) { for(j=0; j<COL; j++) printf("%5d", arr[i][j]); printf("\n"); } } void main() { int *arr; func(&arr); print(&arr); //maybe I'm not passing the arr right ? }

    Read the article

  • Jquery Modal Popup opens twice on Single Click with ASP.Net MVC3

    - by user1704379
    I am using Modal Popup in my MVC3 application it works fine but opens twice for a single Click on the link. The Modal pop is triggered from the 'Index' view of my Home Controller. I am calling a view 'PopUp.cshtml' in my modal popup. The related ActionMethod 'PopUp' for the respective view is in my 'Home' controller. Here is the code, Jquery code on layout.cshtml page, <script type="text/javascript"> $.ajaxSetup({ cache: false }); $(document).ready(function () { $(".openPopup").live("click", function (e) { e.preventDefault(); $("<div></div><p>") .attr("id", $(this).attr("data-dialog-id")) .appendTo("body") .dialog({ autoOpen: true, title: $(this).attr("data-dialog-title"), modal: true, height: 250, width: 900, left: 0, buttons: { "Close": function () { $(this).dialog("close"); } } }) .load(this.href); }); $(".close").live("click", function (e) { e.preventDefault(); $(this).dialog("close"); }); }); </script> cshtml code in 'PopUp.cshtml' @{ ViewBag.Title = "PopUp"; Layout = null; } <h2>PopUp</h2> <p> Hello this is a Modal Pop-Up </p> Call modal popup code in Index view of Home Controller, <p> @Html.ActionLink("Click here to open modal popup", "Popup", "Home",null, new { @class = "openPopup", data_dialog_id = "popuplDialog", data_dialog_title = "PopUp" }) </p> What am I doing wrong that the modal pop up opens twice ? Thanks in Advance !

    Read the article

  • Launching a Facebook page from an iPhone app via QR code

    - by user1655186
    I'm trying to create a QR code that launches a Facebook page from the app, rather than the browser on both Android and iOS. Creating the code with fb://page/<page id>, works perfectly on an Android. This was also supposed to work with iOS's Facebook app, but I think since Facebook updated their app recently from a HTML5 version to a fully native iOS app, that functionality has stopped working. It indeed opens the Facebook app, but it does not go to the page. Has anyone else seen this happen since the app was updated a few weeks ago? And what string would I have to use to create a working QR Code for iOS's Facebook app?

    Read the article

  • How to set HTMLField's widget's height in Admin?

    - by Georgie Porgie
    I have a HTMLField in a model as it's the laziest way to utilize tinymce widget in Admin. But the problem is that the textarea field doesn't have "rows" property set. So the textarea doesn't have enough height comfortable enough for editing in Admin. Is there any way to set the height of HTMLField without defining a ModelAdmin class? Update: I solved the problem by using the following code: def create_mce_formfield(db_field): return db_field.formfield(widget = TinyMCE( attrs = {'cols': 80, 'rows': 30}, mce_attrs = { 'external_link_list_url': reverse('tinymce.views.flatpages_link_list'), 'plugin_preview_pageurl': reverse('tinymce-preview', args= ('tinymce',)), 'plugins': "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", 'theme_advanced_buttons1': "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", 'theme_advanced_buttons2': "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", 'theme_advanced_buttons3': "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", 'theme_advanced_buttons4': "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak", 'theme_advanced_toolbar_location': "top", 'theme_advanced_toolbar_align': "left", 'theme_advanced_statusbar_location': "bottom", 'theme_advanced_resizing': True, 'extended_valid_elements': "iframe[src|title|width|height|allowfullscreen|frameborder|webkitAllowFullScreen|mozallowfullscreen|allowFullScreen]", }, )) class TinyMCEFlatPageAdmin(FlatPageAdmin): def formfield_for_dbfield(self, db_field, **kwargs): if db_field.name == 'content': return create_mce_formfield(db_field) return super(TinyMCEFlatPageAdmin, self).formfield_for_dbfield(db_field, **kwargs)

    Read the article

  • Visualizing Data with the Google Maps API: A Journey of 245k Points

    Visualizing Data with the Google Maps API: A Journey of 245k Points What can you do with some awesome geospatial data, the Google Maps API, and a couple of days of hacking and analysis? Brendan and Paul walk through how they used the Maps API to visualize the CLIWOC database, and pass on tips and trick for doing the same with other geospatial datasets. CLIWOC (Climatological Database for the World's Oceans, 1750-1850): www.ucm.es From: GoogleDevelopers Views: 0 0 ratings Time: 00:00 More in Education

    Read the article

  • Creating a XAML Tile Control

    - by psheriff
    One of the navigation mechanisms used in Windows 8 and Windows Phone is a Tile. A tile is a large rectangle that can have words and pictures that a user can click on. You can build your own version of a Tile in your WPF or Silverlight applications using a User Control. With just a little bit of XAML and a little bit of code-behind you can create a navigation system like that shown in Figure 1. Figure 1: Use a Tile for navigation. You can build a Tile User Control with just a little bit of XAML and...(read more)

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16  | Next Page >