Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
G

gregarion

@gregarion
About
Posts
29
Topics
11
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Error checking
    G gregarion

    Yeap i tried smting like this...

    string NewTitle = "ww";
          string queryText ;
    

    queryText ="Select COUNT(*) from movie_info WHERE movie_title = '"+ NewTitle +"'";

    if (mysql_query(conn,queryText.c_str()) )

    {

    }

    but im not too sure how to get the values out? like if it reads 1 table? how can i call it out?

    C / C++ / MFC database help question mysql

  • Error checking
    G gregarion

    Hey guys i am facing a problem in my sql statement. I am trying to check if there is such a value in the database.

    Code:

      string NewMovie = "ww";
    
      string queryText ;
    

    queryText = "Select * from movie_info WHERE movie_title = '"+ NewTitle +"'";
    MYSQL *conn;

      conn=mysql\_init(NULL);
    
     mysql\_real\_connect(conn,host,username,password,database,0,NULL,0);
    

    mysql_query(conn,queryText.c_str());

       ????
    
      mysql\_close(conn);
    
       
    
      return 0;
    

    The problem i am facing is how do i check if the value is found. I read up and found that a query will return a value of TRUE if the query is a success and a FAIL if there is an error. How do i call these values and then based the check on it?

    C / C++ / MFC database help question mysql

  • Reading variables in Insert Query
    G gregarion

    hmm no, im using c++ actually in netbeans.

    Database database question mysql help

  • Database Syntax
    G gregarion

    C++

    C / C++ / MFC database mysql question

  • Database Syntax
    G gregarion

    Im using netbeans. i dont think there are such libraries

    C / C++ / MFC database mysql question

  • Database Syntax
    G gregarion

    What is MFC and what does "%d" and "%s" stands for?

    C / C++ / MFC database mysql question

  • Problem with query
    G gregarion

    Im not sure what you mean. Could u edit my example to show me what you mean?

    Database database help mysql question

  • Reading variables in Insert Query
    G gregarion

    Sorry i am using netbeans. Is there a way to allow the insert query to read stored variables instead of only having to hardcode it? for example a user enters in the input he wants to store, and then the query will use the variables to be put inside the insert statement.

    Database database question mysql help

  • Reading variables in Insert Query
    G gregarion

    SOrry, I posted this question earlier but it was in the wrong area , so i had to repost it here

    mysql_query(connection, "INSERT INTO main (Name , FriendName) VALUES('Mark', 'John')");

    This coding works fine when i run it in my Netbeans. What i would like to do is instead of having to hardcore the inserted values into the query, i would like it to read from a variable. For exmaple the data to be inserted is from a string... like....

    string NewName= "Monaco";
    string NewFriendName = "Polo";

    How do i edit my sql statements so variables can be inserted into the Insert statement so the query will read the variables and then store their values in the database. Really need some help in this

    Database database question mysql help

  • Problem with query
    G gregarion

    Hey guys I want to insert values into a MySql database. The following line works fine:

    mysql_query(connection, "INSERT INTO main (NumofShows , Title) VALUES('12', 'Home')");

    What i would like to do is instead of having to hardcore the inserted values into the querty, i would like it to read from a variable. For exmaple the data to be inserted is from a string... like....

    string NewTitle = "Monaco";
    string NumofShows = "2";

    How do i edit my sql statements so variables can be inserted into the Insert statement so the query will read the variables and then store their values in the database. Really need some help in this

    Database database help mysql question

  • Database Syntax
    G gregarion

    mysql_query(connection, "INSERT INTO main (NumofShows , Title) VALUES('12', 'Home')")

    Sorry i think you misunderstood what i meant. Normally, for the values, it has to be hardcoded in, for example, having to put 12 and home inside. What i meant is, for example, if the values to be inserted are in a variable , like .. string NewShowName = "Danger" int NewNumberofShow = "2" How do i put in this variables (NewShowName, NewNumberofShow) into the sql statements at VALUES so the program can read the values inside this variables and then save them in the database

    C / C++ / MFC database mysql question

  • Database Syntax
    G gregarion

    Sorry, i do not get u? i mean, how do we insert the variables "NewTitle" and "NumofShows" into the sql statement so it can read the varaibles..

    C / C++ / MFC database mysql question

  • Database Syntax
    G gregarion

    Could you explain how i can insert it into my sql query to show how it works?

    C / C++ / MFC database mysql question

  • Database Syntax
    G gregarion

    Hey guys I want to insert values into a MySql database. The following line works fine:

    mysql_query(connection, "INSERT INTO main (NumofShows , Title) VALUES('12', 'Home')");

    but if the data to be inserted is from a string... like....

    string NewTitle = "Monaco";
    string NumofShows = "2";

    What can i do so it will be able to read the strings and use their values to be inserted into the data table?

    C / C++ / MFC database mysql question

  • Problem with output [modified]
    G gregarion

    Hey guys, i am having problem with displaying my text. my text file is displayed in such a way and is called test.......

    Sam Worthington ... Jake SullyasZoe Saldana ... NeytiriasSigourney Weaver ... Dr. Grace AugustineasStephen Lang ... Colonel Miles QuaritchasJoel Moore ... Norm Spellman (as Joel David Moore)asGiovanni Ribisi ... Parker SelfridgeasMichelle Rodriguez ... Trudy ChaconasLaz Alonso ... Tsu'teyasWes Studi ... EytukanasCCH Pounder ... MoatasDileep Rao ... Dr. Max PatelasMatt Gerald ... Corporal Lyle WainfleetasSean Anthony Moran ... Private FikeasJason Whyte ... Cryo Vault Med TechasScott Lawrence ... Venture Star Crew Chiefmore

    What i am trying to do is for the program to read "as" and then from there start a new line... thus the expected output is...

    Sam Worthington ... Jake Sully
    Zoe Saldana ... Neytiri
    Sigourney Weaver ... Dr. Grace Augustine
    Stephen Lang ... Colonel Miles Quaritch
    Joel Moore ... Norm Spellman (as Joel David Moore)
    .........(and so on)

    This is my coding..

    string templine ;
    string line;
    ifstream myfile ("test");

    while (getline (myfile,templine) )
    line.append(templine);

    char str [] = line ;
    char delims[] = "as";
    char *result = NULL;
    result = strtok( str, delims );
    while( result != NULL ) {
    printf( result );
    result = strtok( NULL, delims );
    }

    I keep getting the error saying ...

    editmain.cpp.98:error: initializer fails to determine size of 'str'

    modified on Monday, February 8, 2010 1:41 PM

    C / C++ / MFC help c++

  • Formatting text based on delimeter
    G gregarion

    Hey guys, i am having a problem formatting my text in a file. what i did was to extract some information from a html file and i would like to format it. Currently my information comes out in this way...

    Code: Select all
    Cast (Cast overview, first billed only), Sam Worthington ... Jake Sully ,Zoe Saldana ... Neytiri ,Sigourney Weaver ... Dr. Grace Augustine ,

    what i would like to achieve is for the program to read the "," and then based on then "," paste it to a newline and continue.. for example...

    Code: Select all
    Cast (Cast overview, first billed only)
    Sam Worthington ... Jake Sully ,
    Zoe Saldana ... Neytiri ,
    Sigourney Weaver ... Dr. Grace Augustine

    Anybody can give some clue on how i can format my text according to this way? Hope for some help in this. Thanks!

    C / C++ / MFC help html tutorial question

  • Declaring Variables
    G gregarion

    Okay , that sounds complicated. Basically why i need it to store the output given out in a certain class is because i need to use it for cppunit testing later on. Basically, each class in my project will give out a certain output based on the document it reads For example, classA gives an output of 333. ClassB gives an output of 434. what i was trying to do is to try to save this values in a way that when i write my cppunit, i can use it to check if it is equal to the hardcoded input.

    C / C++ / MFC help question

  • Declaring Variables
    G gregarion

    What should i be looking for exactly when i read the book?

    C / C++ / MFC help question

  • Declaring Variables
    G gregarion

    Sorry , let me try to make it clear. For example, in class A, it will extract a certain value. What i want to do is to save this value in a way that it can be called out in any other classes, either for just displaying the information or to do some calculations.

    C / C++ / MFC help question

  • Declaring Variables
    G gregarion

    Hey guys im facing a problem in declaring variables. i have a few classes like the one below...

    [CODE]#ifndef _FINANCE_H
    #define _FINANCE_H

    #include <string>
    #include <iostream>
    #include <fstream>
    #include <stdlib.h>

    using namespace std ;

    class readStraitsTimesIndex
    {
    public:
    void StraitsTimesIndex(fstream&) ;
    private:
    };

    class readDow
    {
    public:
    void Dow(fstream&) ;
    private:
    };
    [/CODE]

    what i am trying to do is to use a value which is being the output of one of the class class and to be displayed into the other class. I tried using an object member like the one below ,

    [CODE]class readStraitsTimesIndex
    {
    public:
    void StraitsTimesIndex(fstream&) ;
    String value ;
    private:

    };[/CODE]

    and then assigned the output of that class to the variable(value) , but it will only work within the class. how do i go about saving a certain variable from the output of a certain class and using it for the other variables.

    C / C++ / MFC help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups