phorce 131 Posting Whiz in Training Featured Poster

Hello,

I'm trying to read the header information of a .wav file and I'm kind of stuck.

Basically, the header information is located at different offsets in the file. So for example:

(0-4) = ChunkID
(4-8) = ChunkSize
(8-12) = Format
.. ..
.. ..
.. ..

From this: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/

Now the problem I'm having is when I try to read the data like this, the data does not store correctly and I end up with missing data. This is the code I have written:

bool Wav::readHeader(FILE *dataIn)
{
    // RIFF
    int i=0;

    fread(this->chunkId, sizeof(char), 4, dataIn);
    i += 4;

    fread(&this->chunkSize, sizeof(int), 1, dataIn);

    fread(this->format, sizeof(char), 4, dataIn);

    cout << "RIFF DATA" << endl;

    cout << "Chunk ID: " << this->chunkId << endl;
    cout << "Chunk Size: " << this->chunkSize << endl;
    cout << "Format: " << this->format << endl;

    fread(this->formatId, sizeof(char), 4, dataIn);
    fread(&this->formatSize, sizeof(int), 4, dataIn);
    fread(&this->format2, sizeof(short), 2, dataIn);
    fread(&this->numChannels, sizeof(int), 2, dataIn);
    fread(&this->sampleRate, sizeof(int), 4, dataIn);

    cout << endl << endl;
    cout << "FORMAT DATA" << endl;
    cout << "Format ID: " << this->formatId << endl;
    cout << "Format S: " << this->formatSize << endl;
    cout << "Format SS: " << this->format2 << endl;
    cout << "Channels: " << this->numChannels << endl;
    cout << "Sample Rt: " << this->sampleRate << endl;
    return true;
}

Here are the class members/variables:

// Define the class-variables for the Header Information
           // riff
           char chunkId[4];
           int chunkSize;
           char format[4];

           // …
phorce 131 Posting Whiz in Training Featured Poster

This made me laugh, a tiny bit. Thank you :)

phorce 131 Posting Whiz in Training Featured Poster
<?php
ob_start();
session_start();
include('./config.php');

//protect SQL injection
$username = $_POST['username'];
$password = $_POST['password'];
$username = stripslashes($username);

$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$password=hash('sha256',$password);


//SQL query that sent login info to database


$result = mysql_query ("SELECT * FROM admin WHERE Login ='$username' AND Password ='$password'",$con);
$check = mysql_num_rows ($result);

if ($check == 1){
    while($rows = mysql_fetch_array($result)){
    $_SESSION['adminID'] = $rows['ID'];
    $_SESSION['username'] = $username;
        header('Location: ../home.php');
}
}

else {
    header('Location: ../index.php');

}


?>

Username will work, however, are you sure that 'ID' actually exists in the database?

phorce 131 Posting Whiz in Training Featured Poster

Well.. I offically feel stupid. Problem solved, It's late and my brain doesn't function after a certain time!

phorce 131 Posting Whiz in Training Featured Poster

Hello,

Do you expect someone to code this for you, for free? That's just plain cheeky!!

There are freelance websites out there, obviously, they'll charge you!!

phorce 131 Posting Whiz in Training Featured Poster

Hello, wondering if someone can help me.

I'm working with a .wav file, and, I need to collect the header information. The header contains (roughly, 20 bits/bytes) before the actual data. And, each of this data is contained at different locations in the file. I need to read a particular amount of integers in the text. For example:

Data = 

    102030405060

For the first header information, I need to gather the first 4 integers.. So:

Data = {
         10
         20
         30
         40
       }

The code that I have written, reads in the first integers, however, reads them like this:

  Data = {
         1
         0
         2
         0
       }

This is obviously wrong, but, I can't figure out how to read the whole of the integer inside element[0]..[3] - Here is the code: (Data type is char)

bool Wav::readHeader(ifstream& dataIn)
{
    // READ and VALIDATE the Type
    dataIn.read(this->type, 4);

    for(unsigned i=0; (i < 4); i++)
    {
        cout << this->type[i] << endl;
    }
    // testing purposes
    return true;
}

Could anyone offer any solutions?

Thank you very much :)!

phorce 131 Posting Whiz in Training Featured Poster

Can you not just take some code, then go onto different forums (Java, C++) etc.. and ask what the code is, if you don't know what the code does, or, even what language it is in; why are you using it?

It looks like Perl, or, some other scripting language..

phorce 131 Posting Whiz in Training Featured Poster

Hello,

I'm trying to write the Cooley Turkey algorithm for an FFT. Now, The algorithm works well, but, only for 2 numbers - Nothing else. For example, I have used an online FFT calculated, entered the same data and got the same results. Here is the code for the algorithm:

#include <iostream>
#include <math.h>
#include <vector>
#include <complex>

using namespace std;

#define SWAP(a,b) tempr=(a);(a)=(b);(b)=tempr;
#define pi 3.14159

void ComplexFFT(vector<float> &realData, vector<float> &actualData, unsigned long sample_num, unsigned int sample_rate, int sign)
{
    unsigned long n, mmax, m, j, istep, i;
    double wtemp,wr,wpr,wpi,wi,theta,tempr,tempi;

    // CHECK TO SEE IF VECTOR IS EMPTY;

    actualData.resize(2*sample_num, 0);

    for(n=0; (n < sample_rate); n++)
    {
        if(n < sample_num)
        {
            actualData[2*n] = realData[n];
        }else{
            actualData[2*n] = 0;
            actualData[2*n+1] = 0;
        }
    }

    // Binary Inversion
    n = sample_rate << 1;
    j = 0;

    for(i=1; (i< n); i+=2)
    {
        if(j > i)
        {
            SWAP(actualData[j - 1], actualData[i - 1]);
            SWAP(actualData[j], actualData[i]);
        }
         m = sample_rate;
         while (m >= 2 && j > m) {
          j -= m;
          m >>= 1;
         }
         j += m;
     }
     mmax=2;

     while(n > mmax) {

        istep = mmax << 1;
        theta = sign * (2*pi/mmax);
        wtemp = sin(0.5*theta);
        wpr = -2.0*wtemp*wtemp;
        wpi = sin(theta);
        wr = 1.0;
        wi = 0.0;

        for(m=1; (m < mmax); m+=2) {
            for(i=m; (i <= n); i += istep)
            {
                j = i + mmax;
                tempr = wr*actualData[j-1]-wi*actualData[j];
                tempi = wr*actualData[j]+wi*actualData[j-1];

                actualData[j-1] = actualData[i-1] - tempr;
                actualData[j] = actualData[i]-tempi;
                actualData[i-1] += tempr;
                actualData[i] += tempi;
            }
            wr = (wtemp=wr)*wpr-wi*wpi+wr;
            wi …
phorce 131 Posting Whiz in Training Featured Poster

Hello,

Thank you for your reply.. I want to read in .wav files and from reading on the internet, will produce some values, do I need to implement an FFT in order to get the frequency of the .wave file?

Thanks

phorce 131 Posting Whiz in Training Featured Poster

Hello,

I'm wondering if anyone knows if there is a specific way or a library that allows me to read in an audio file in which I can then manipulate and get the different frequencies?

I'm basically trying to make an application that uses an FFT for the audio signals and then determine if the person on the voice clip is male or female.

Can anyone offer any advice please?

Thanks

phorce 131 Posting Whiz in Training Featured Poster

What is the error?

phorce 131 Posting Whiz in Training Featured Poster

You've got more chance of finding a blonde virgin than finding a two worded domain ;-)

phorce 131 Posting Whiz in Training Featured Poster

Hey there,

Possibly. PHP doesn't (that I know of) gain access to your computer without you being on a server, it is server-side and therefore needs to be on a server. You would therefore have to specifically download something and then run the application. Most of the links that you will be recieiving will be "Phishing" and some maybe able to access your COOKIES but that's about it. Just make sure you have a good anti-virus and firewall blocking them! Hope this helps :)

phorce 131 Posting Whiz in Training Featured Poster

Don't think I quite understand, or, if I do, why would you want to do such a thing..

Ok, have a form that asks the user if (s)he is a user or a re-seller. Then, create a database that stores this information. Everytime you want to check, you can check to see if the IP address matches the re-sellers/users IP stored within the database. What if the user's IP address changes? What if they access a different computer? Is this therefore a really efficent way to identifying someone?

phorce 131 Posting Whiz in Training Featured Poster

Try including the "session.php" before "connecting.php" :)

phorce 131 Posting Whiz in Training Featured Poster

Good luck in whatever you decide! If you require further assistance, feel free to post!

phorce 131 Posting Whiz in Training Featured Poster

Okay,

Me personally, I would do this:

Take the ASP course to get to grips with some web programming and get to grisps with the language.

Either take the C++ or Java course. I would personally take the C++ over Java but then again I enjoy coding C++. If you can take Java in the spring, brilliant! Go ahead and do it.

Taking this path, to me will give you an insight in to what you want to do in your future. But, remember, you don't have to decide what you want to do now, it's all about learning experiences. I wanted to be a lawyer during school, I'm now programming? Someone I know did their degree in medicine and now runs a design company. Don't assume you "want to know everything there is about programming" because the chances are, even if you spent from now until you were 50 - you would not have grasped the full concepts as this is an ever changing enviroment.

phorce 131 Posting Whiz in Training Featured Poster

Stick to the C++ aspect of the course, it'll come in handly later on. Take a web course (ASP/PHP) as these two languages are really useful as well, especially in todays market where things are moving towards web programming. I learnt PHP then C++ then I moved into Java and by learning PHP I was able to pick up on C++ and by learning C++ I was able to pick up on Java..

P.S. By learning ASP (especailly ASP.NET) it may open you up to learning languages such as C# which can the easily be adapted and work with each other.

phorce 131 Posting Whiz in Training Featured Poster

Excuse me? What do you think this is? Lol. Don't come here asking/demanding code to be written for you, atleast make an attempt. There are services out there, in which you can PAY developers to make such things.

phorce 131 Posting Whiz in Training Featured Poster

ll concerned abo

@Helianthus - In my opinion, learning C++/C will open you up to learning other languages, it will give you that foundation or stepping stone and other languages syntax will become more familiar. Obviously, if you want such jobs as a C++ programming, then, you have to be really good at what you do and understand the concepts. REMEMBER, it's not about what language you can code in, it's about learning the logic. YOU SHOULD be able to take a particular problem, find out the best solution and in the best language and then go from there.

Hope this helps

phorce 131 Posting Whiz in Training Featured Poster

No problem mate :) Good luck with it! Please mark this thread as solved, if you haven't done so already! Get some sleep haha

phorce 131 Posting Whiz in Training Featured Poster

I don't get an error message doing this:

<?php

//connect to database, checking, etc
include_once "connect.php";

// process form when posted
if(isset($_POST['value'])) {


    if($_POST['value'] == 'Kulp') {
        // query to get all Kulp records  
        $query = "SELECT * FROM names WHERE LastName='Kulp'"; 
        $sql = mysql_query($query);  
    }  
    elseif($_POST['value'] == 'Smith') {  
        // query to get all Smith records  
        $query = "SELECT * FROM names WHERE LastName='Smith'";  
        $sql = mysql_query($query); 
    } else {  
        // query to get all records  
        $query = "SELECT * FROM names"; 
        $sql = mysql_query($query);  
    }  
    while ($row = mysql_fetch_array($sql)){ 
        $Id = $row["Id"]; 
        $FirstName = $row["FirstName"]; 
        $LastName = $row["LastName"]; 

        // Echo your rows here... 
        echo 'The user ID is:' . $row['id'];
    }
 }
?>

I don't have your server, so I can't really test it.. But give it a try..

jkulp4 commented: Quick reply and very helpful +0
phorce 131 Posting Whiz in Training Featured Poster

Hey, please try the following:

<html>
<Head>
<Title>Drop Down Choice Example</title>

<?php

//connect to database, checking, etc
include_once "connect.php";

// process form when posted
if(isset($_POST['value'])) {
    if($_POST['value'] == 'Kulp') {
        // query to get all Kulp records  
        $query = "SELECT * FROM names WHERE LastName='Kulp'";  
    }  
    elseif($_POST['value'] == 'Smith') {  
        // query to get all Smith records  
        $query = "SELECT * FROM names WHERE LastName='Smith'";  
    } else {  
        // query to get all records  
        $query = "SELECT * FROM names";  
    }  
    $sql = mysql_query($query);  

    while ($row = mysql_fetch_array($sql)){ 
        $Id = $row["Id"]; 
        $FirstName = $row["FirstName"]; 
        $LastName = $row["LastName"]; 

        // Echo your rows here... 
        echo 'The user ID is:' . $row['id'];
    }
 }
?>
</head>

<body>
<P>Please select from below<p><BR>

<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post' name='form_filter' >
        <select name="value">
        <option value="All">All</option>
        <option value="Kulp">Kulp</option>
        <option value="Smith">Smith</option>
    </select>
    <br />
    <input type='submit' value = 'Filter'>
</form>

Your problem is that $query just stores what the query should perform, and, $sql is what executes the query, therefore, you need to pass in this value rather than the string.

Hope this solves your problem

phorce 131 Posting Whiz in Training Featured Poster

Hello, wondering if someone can help me quickly..

Basically, I have created a array to store all the data in a text file. The pointer of the array is sent to a function, which then populates it. Here is the code:

void Data(char* theData)
{
    ifstream txtFile(inputFile.c_str());
    if(!txtFile.is_open())
    {
        cerr << "Cannot open text file";
    }

    char getData[100000];
    txtFile.read(getData, sizeof getData);

    theData = getData;
}

int main(int argc, char *argv[]) {

    char* data;
    Data(data);

    cout << data[0];

}

I get a segmentation fault, and I think it's to do with how I'm copying getData into theData.

Could anyone help ?

Thanks

phorce 131 Posting Whiz in Training Featured Poster

C K F H D B G

Hey, do you have an image of what the tree actually looks like?

Thanks :)

phorce 131 Posting Whiz in Training Featured Poster

You forgot to mark the thread as solved, too busy talking to yourself ;)

phorce 131 Posting Whiz in Training Featured Poster

Sorry, my last comment was invalid. Can you tell me what $var actually does? Is it something on the form? If so, couldn't you just have it as an hidden field and then post it across? The aother alternative might be to decide what your form does by using $_GET.

phorce 131 Posting Whiz in Training Featured Poster

Just a suggestion..

The $var will be stored in temp memory, and, when you re-load the page, the $var value will therefore be cleared. Why not store it as a session?

phorce 131 Posting Whiz in Training Featured Poster

Ok, nearly right.. I think..

I'm going to assume, from what you've told me that the program will work as follows:

  1. The user is asked the input the amount of products they wish to insert
  2. An array of Objects is defined with the length of how many products has to be inserted.
  3. The products are then inputted into the correct object (array), e.g. Product 1 will be p[0], product 2, p[1]
  4. The user can then input which product he/she would like to search for, using the product number. in this case, they would enter the location of the object in the array. (For product 1, enter 0 etc).. Each product will therefore have a unique number, as it will be stored in the array.

Take a look at this example, I cannot complete it for you, as I get bad rep for that (hehe) but it should give you some indication to how to move forward in solving this problem.

#include <iostream>

using namespace std;

class product
{

    string product_name;
    int code;
    float price;
    int stock;
        public:
        void getProduct(void);
        void display(void);
};

    void product::getProduct(void)
    {
        cout << "Enter product name: \n";
        cin >> product_name;
        cout << "Enter product code: \n";
        cin >> code;
        cout << "Enter price of product: \n";
        cin >> price;
        cout << "How many in stock? \n";
        cin >> stock;
    }

    void product::display(void)
    {
        cout << "\nProduct name: " << product_name;
        cout << "\nProduct code: " << code;
        cout << "\nPrice: " << price;
    }; …
phorce 131 Posting Whiz in Training Featured Poster

Hello,

To answer your question regarding what "int GetProduct();" should do. Well, it could do a lot of things things, here's some suggestion:

  • Let's assume you're entering the data, and you have a vast amount of products and
    you need to locate a particular product, each product therefore has it's own ID number which can be located inside the array. Therefore, "int getProduct(int theIdNumber);" which would then search through the array for the particular ID and then once found, display that particular ID. (I did something similar for a games store as an assignment).

  • The other assumtion is that your assessor or lecturer wants you to move into "sets" and "gets" approach to classes. You have three variables, code, price, stock and product number. Each of these class variables has to be set and each of these variables have to be returned. Ok, here's an example (Not compiled):

      void setCode(int theCode)
      {
    
      }
    
      void setPrice(float thePrice)
      {
    
      }
    
      void setStock(int theStock)
      {
    
      }
    
      void setProductName(string theName)
      {
    
      }
    

These are your SET'S. They set the variables from main.

Let's look at GET'S:

    int returnCode()
    {
       // return the class variable name for code
    }

    float returnPrice()
    {

    }

    int returnStock()
    {

    }

    string returnName()
    {

    }

Hope this helps you :)

phorce 131 Posting Whiz in Training Featured Poster

Ok, so the question is this:

Question (inb4 dwight schrute)
A class called 'sample' with the data a, b and c and two methods as defined below. Define a new member method 'term()' which calculates the value of the term (2b - 4ac) and displays it.

Define the method outside of the class definition. Write the main method to create an array of 2 objects called D of class 'sample' and display the values and find the solution to the term (2b - 4ac)

  • You have a class called 'sample'
  • You have data (a, b, c)
  • Two methods inside the class
  • Method "term()" I believe HAS to be inside the class (But I might be wrong), the task says DEFINE, nothing about implementing it outside of the class, but, again, I might be wrong.
  • You also should think about making each of the methods, actual methods. At the moment, they seem to be just functions.. Not properties of the class. To do this, do, void sample::setdata()

I don't understand why they have asked you to do this, since, it's the wrong way of using classes. You SHOULD define the protection in the class, public, private, protected etc..

Also, like I said before.. Avoid using "cout" and "cin" inside your class, this should be handled in your MAIN. Accept parameters that are inputted through main, return values in your methods.

Are you sure your reading the question right? It says "define the method outside of the …

phorce 131 Posting Whiz in Training Featured Poster

Hey there, nice attempt.

When using classes, you should remember that your class definition should be in a (.h) file, and then class methods/functions should be in it's own seperate (.cpp) file. Let me show you an example:

Sample.h:

class Sample {

    public:
        Sample();
        int term(int a, int b, int c);
        void setData(int a, int b, int c);
        int returnA1();

     private:
        int a1, b1, c1;
};

Sample.cpp:

Sample::Sample(){}
void Sample::setData(int a, int b, int c)
{
    this->a1 = a;
    this->b1 = b;
    this->c1 = c;

}
int Sample::returnA1()
{
    return this->a1;
}

int Sample::term(int a, int b, int c)
{
    int result = (2*b - 4*a*c);
    return result;
}

A few errors in your main:

1) You defined an array of class objects, so you need to define which object you're wishing to use. E.g.

Before:

d.setdata();

How it should be done:

d[0].setdata();
// or
d[1].setdata();

Remember you've initalised an array of 2, which starts at 0.

Also IMO classes should not specifically ask for input, or, use commands like "cout", this is because you may want to use the class in the future for other applications other than console based.

I have included a working version of your script, but, remember the points above!!

#include <iostream>

using namespace std;

class Sample {

    public:
        Sample();
        int term(int a, int b, int c);
        void setData(int a, int b, int c);
        int returnA1();


        int a1, b1, c1;
};

Sample::Sample(){}

void Sample::setData(int a, int …
phorce 131 Posting Whiz in Training Featured Poster

Well, have you got a login script that handles if the user has entered the correct details? If this is the case, you can use sessions to determine whether or not the user is signed in, or not.. And then which link/data you want the user to see

phorce 131 Posting Whiz in Training Featured Poster

Try this:

<?php
//init.inc.php file

session_start();

// Get users from table
function fetch_users() {

$query = mysql_query('SELECT `user_id` AS `id`, `user_name` AS `username` FROM profile');

$users = array();

while(($row = mysql_fetch_assoc($query)) !== false)
{
    $users[] = $row;

}
return $users;
}
?>

I'm an idiot.. Sorry!

phorce 131 Posting Whiz in Training Featured Poster

Try this:

<?php
//init.inc.php file

session_start();

mysql_connect('mysql.host.com', 'username', 'password') or die(mysql_error());
mysql_select_db('DB name');

include('include'); // whatever your including, meh!

// Get users from table
function fetch_users() {

$query = "SELECT user_id AS id, user_name AS username FROM profile";
$result = mysql_fetch_array($query);

$users = array();



while ($row = mysql_fetch_assoc($result) !== false) {

     $users[] = $row; // you need to specificially identify which row to include, e.g. $row['username'];
}

return $users;

}

?>
phorce 131 Posting Whiz in Training Featured Poster

What?

I'm confused, do you expect someone to check what domain names are free or not? :S That's a pretty extreme thing to ask for ha!

http://www.fasthosts.co.uk/domain-names/ try this or who 'whois {domain_name}' in terminal/cmd

phorce 131 Posting Whiz in Training Featured Poster

Aha no problem :) Good luck with your application, if you need help with anything else - Please feel free to post!

phorce 131 Posting Whiz in Training Featured Poster
<?php
    // connection details
    // connection details

    $sql = "SELECT * FROM {table}";
    $result = mysql_query($sql) or die(mysql_error());
    if(mysql_affected_rows() >= 1)
    {
        while($row = mysql_fetch_array($result))
        {
            $image_url = $row['url'];
        }

        echo "http://localhost/htdocs/image_folder" . $image_url . ".jpg";

    }
?>

Have not tested it, should give you a rough idea :)!

phorce 131 Posting Whiz in Training Featured Poster

mysql_query("DELETE FROM gigs WHERE gigname='".$name."'");

Try:

mysql_query("DELETE FROM gigs WHERE gigname='$name'");

Other than that, output $name

phorce 131 Posting Whiz in Training Featured Poster

Thank you very much :)

phorce 131 Posting Whiz in Training Featured Poster

@Ancient Dragon

What if there is more than 4 coords? If it was dynamically populated? (I will eventually change this to a vector)..

But, if the image had 3 points on it, there'd be 6.. Would I need a loop then?

phorce 131 Posting Whiz in Training Featured Poster

Hello,

I'm trying to develop an algorithm/program that calculates the distance between two points. These values are stored inside a 1D array, which, acts as a 2D array (I think you know what I mean!) The values are:

150 50
15 20

The calculation should therefore be:

d = √(150 - 15)² + (50 - 20)²

Here is the code I've written (Ok, I know it's not the best way, just testing):

#include <iostream>
#include <math.h>
using namespace std;
int main(int argc, char *argv[]) {

    int coord[2*2] = {150, 50, 
                      15, 20};

    double distance = 0;
    double dis1 = 0;
    double dis2 = 0;

    for(int i=0; (i < 2); i++)
    {
        for(int j=0; (j < 2); j++)
        {
            dis1 = (coord[i*2+j]-coord[i*2+j])*(coord[i*2+j]-coord[i*2+j]);
            dis2 = (coord[i*2+j]-coord[i*2+j])*(coord[i*2+j]-coord[i*2+j]);

        }
        cout << endl;
    }

    distance = sqrt(dis1+dis2);

    cout << distance;
}

Anyone offer any solutions?

Thanks :)

phorce 131 Posting Whiz in Training Featured Poster

Okay, did you try the code? It should work!

phorce 131 Posting Whiz in Training Featured Poster

Okay, let me know how it goes :)!

phorce 131 Posting Whiz in Training Featured Poster

Are you sure this is the correct method to completing this?

I mean, if there are 1-22 sets, are you going to have an if statement for each set?

phorce 131 Posting Whiz in Training Featured Poster

Ok.

Can you please tell me what the result of this is:

<?php

$host="mysql6.000webhost.com"; // Host name 
$username="removed"; // Mysql username 
$password="removed"; // Mysql password 
$db_name="removed"; // Database name 
$tbl_name="direct"; // Table name


// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("Error. MySQL Not Responding.");

$SQL = "SELECT url FROM $tbl_name";
$result = mysql_query($SQL);

if(mysql_affected_rows() == 1) // assuming there is only ONE url inside the table
{
    $row = mysql_fetch_row($result);
    $url = $row[0];
    var_dump($url);
    //header("Location: $url");
}else{
  echo 'Cannot fetch the URL';  

}
?>

It will give either NULL, or a string value.. Please post this!!!

phorce 131 Posting Whiz in Training Featured Poster

Try this:

<?php

$host="mysql6.000webhost.com"; // Host name 
$username="removed"; // Mysql username 
$password="removed"; // Mysql password 
$db_name="removed"; // Database name 
$tbl_name="direct"; // Table name


// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("Error. MySQL Not Responding.");

$SQL = "SELECT url FROM $tbl_name";
$result = mysql_query($SQL);

if(mysql_affected_rows() == 1) // assuming there is only ONE url inside the table
{
    $row = mysql_fetch_row($result);
    $url = $row[0];
    header("Location: $url");
}else{
  echo 'Cannot fetch the URL';  

}
?>
Djmann1013 commented: Thank you for helping me. I was literally tearing my hair out. +1
phorce 131 Posting Whiz in Training Featured Poster

Hey first off, for your own purpose, please don't post your MYSQL Account information on a public forum that anyone can see ;)

Second, can you please just var_dump the $url variable where you're trying to re-direct.. So for example:

db_field

<?php

$host="mysql6.000webhost.com"; // Host name 
$username="removed"; // Mysql username 
$password="removed"; // Mysql password 
$db_name="removed"; // Database name 
$tbl_name="direct"; // Table name


// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("Error. MySQL Not Responding.");

$SQL = "SELECT * FROM $tbl_name";
$result = mysql_query($SQL);

while ($db_field = mysql_fetch_assoc($result)) {
$url = $db_field['url'];
}

var_dump($url);
//Banned st00f...
//include('/home/a1092592/public_html/ban/banned.php');
//redirect....
 //  header("location:$url");

?>

Then post the the result.. :)

phorce 131 Posting Whiz in Training Featured Poster

Hey,

I'm guessing 1 = active, 2 = not active..

<?php

    mysql_select_db("my_db", $con);

    $result = mysql_query("SELECT * FROM gameChart WHERE secID=='1'");
    echo "<dl><dt>Writer's Forge</dt>";

    if(mysql_affected_rows() == 1)
    {
        echo "<dd>Collaborated Poetry</dd>";

    }else{
    echo "<dd><a href='showcase'>Collaborated Sreenplays</a></dd>";

    }


?>

Could try this.. I mean, I'm not too sure why you need to fetch the row, only if you wanted to display the actual row that I would do this.

This might helo you :)

phorce 131 Posting Whiz in Training Featured Poster

Hey, you could try this:

Hey, you could try this:



    <?php

    include 'connect/connect.php';

    if(isset($_POST['sub'])) {
        $bcode = $_SESSION['barcode_v'];
        $iname = $_POST['u_name_f'].' '.$_POST['u_name_l'];
        $name = stripcslashes(strip_tags($iname));
        $email = $_POST['email'];
        $dob =  stripcslashes(strip_tags($_POST['y']."-".$_POST['m']."-".$_POST['d']));
        $insti = stripcslashes(strip_tags($_POST['insti']));
        $phone = $_POST['phone'];
        $course = $_POST['course'];
        $school = $_POST['school'];
        $address = $_POST['address'];

            $sql2 = "SELECT * FROM appthing WHERE barcode='$bcode'";
            $query2 = mysql_query($sql2);
            if(mysql_affected_rows() != 1)
            {
            echo '<div style="background-color:white; color-black;">';
            echo 'Invalid Code '.$bcode.' '.$row2['barcode'];
            echo '</div>';
            } else {

                if (!preg_match('/[^A-Za-z]+/', $name)) {
                    if (($_POST['y'] > 1950 && $_POST['y'] < 2005) && ($_POST['m'] > 0 && $_POST['m'] < 13) && ($_POST['d'] > 0 && $_POST['d'] < 32)) {
                        if (!preg_match('/[^0-9]+/', $phone) && strlen($phone) == 10) {
                            $query = "UPDATE appthing SET name=$name, email=$email, dob=$dob, insti=$insti, phone=$phone, school=$school, course=$course, address=$adress WHERE barcode=$bcode";
                            mysql_query($query) or die(mysql_error());

                            $to = $email;
                $subject = "Tafconnect.com";
                $message = "Hello! $name,<br />Registration Details  <br /> Barcode : $bcode <br /> Contact : $phone <br /> DOB : $dob<br /><br />Thank you for registering your application";
                $from = "admin@tafconnect.com";
                $headers = "From:" . $from;
                mail($to,$subject,$message,$headers);

                            echo '<div style="background-color:white; color-black;">';
                            echo $name.', you have been registered! Please check back after 5th August for your interview schedule. Also check your mail for the registered details. Redirecting in 10 seconds';
                            echo '</div>';
                            echo '<meta http-equiv="refresh" content="10;URL=index.php">';
                        } else {
                            echo 'Invalid Phone Number';
                        }
                    } else {
                        echo 'Invalid DOB';
                    }
                } else {
                    echo 'Invalid Name';
                }

            } 
        }

    ?>

Haven't tested it, don't have access to your table but it might work! …