Page 2 of 2

Posted: Tue May 15, 2007 3:29 pm
by guitarlvr
well in your original $insert = mysql_query(INSERT INTO........ you were running the query there then running it again and storing it under $result. I think thats why the query was empty cause it had already run. Is there any information in that table at all? I think there should be as it had already ran. essentially, you want to build the query into the $insert var and then run the query and assign that to $result.

Wayne

Posted: Tue May 15, 2007 3:31 pm
by guitarlvr
I'm not a PHP expert by any means as I haven't been coding that long but I don't understand why you need to concatenate all those variables. I would think that would cause a problem to but i guess not.

Posted: Tue May 15, 2007 3:41 pm
by toby_c500
Cheers for helping me Wayne.

I have just run with what you mentioned earlier about the concats and got:


Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /Applications/MAMP/htdocs/register.php on line 25.

When you say I am running the query twice. What do you mean? $insert once and then where? I think that is probably the key.

Posted: Tue May 15, 2007 3:47 pm
by guitarlvr
You are running the query everytime you use mysql_query() function. $insert = mysql_query() and $result = mysql_query().

Can you repost the code that you have. You've changed quite a few things since you've posted it last. Also, what is line 25?

Wayne

Posted: Tue May 15, 2007 3:57 pm
by toby_c500
Line 25 is the first line of VALUES.

I have changed the concats back now as you can see. This just shows up the empty query statement.

Code: Select all

<?php
$link = mysql_connect('localhost', 'root', 'root');

if(!$link){
        echo "Sorry, we are having a few problems with our system. Please try again later. link";
        exit;
}
else{
        echo "Your details have been stored in our database. Use the the navigation bar at the top to look for jobs.";
}

$db = mysql_select_db('jobs4alltrades', $link);
if (!$db) die('could not select the database');

$insert = mysql_query("INSERT INTO members (loginid, password, firstname, surname, email,
                                                        trade, address1, address2, address3, address4,
                                                        postzip, country, yearsexp, about)
                               VALUES ('".$_POST['loginid']."', '".$_POST['password']."', '".$_POST['firstname']."',
                                                '".$_POST['surname']."', '".$_POST['email']."', '".$_POST['trade']."', '".$_POST['address1']."',
                                                '".$_POST['address2']."', '".$_POST['address3']."','".$_POST['address4']."', '".$_POST['post']."',
                                                '".$_POST['country']."','".$_POST['yearsexp']."','".$_POST['about']."')");

$result = mysql_query($insert, $link) or die("Query: $insert\n<br /.> MySQL Error: " . mysql_error());


?>

Posted: Tue May 15, 2007 3:59 pm
by toby_c500
is it not a different query when the ($var)'s are different?

Posted: Tue May 15, 2007 4:00 pm
by guitarlvr
still looks like its being done twice, try this:

Code: Select all

<?php
$link = mysql_connect('localhost', 'root', 'root');

if(!$link){
        echo "Sorry, we are having a few problems with our system. Please try again later. link";
        exit;
}
else{
        echo "Your details have been stored in our database. Use the the navigation bar at the top to look for jobs.";
}

$db = mysql_select_db('jobs4alltrades', $link);
if (!$db) die('could not select the database');

$insert = "INSERT INTO members (loginid, password, firstname, surname, email,
                                                        trade, address1, address2, address3, address4,
                                                        postzip, country, yearsexp, about)
                               VALUES ('".$_POST['loginid']."', '".$_POST['password']."', '".$_POST['firstname']."',
                                                '".$_POST['surname']."', '".$_POST['email']."', '".$_POST['trade']."', '".$_POST['address1']."',
                                                '".$_POST['address2']."', '".$_POST['address3']."','".$_POST['address4']."', '".$_POST['post']."',
                                                '".$_POST['country']."','".$_POST['yearsexp']."','".$_POST['about']."')";

$result = mysql_query($insert, $link) or die("Query: $insert\n<br /.> MySQL Error: " . mysql_error());


?>

Posted: Tue May 15, 2007 4:11 pm
by toby_c500
its just echoed the INSERT INTO line with values.

The error: MySQL Error: Unknown column 'address3' in 'field list' has shown at the bottom.

Posted: Tue May 15, 2007 4:13 pm
by guitarlvr
Are you positive that address3 is spelled that way in the table?

Wayne

Posted: Tue May 15, 2007 4:15 pm
by toby_c500
Wayne. Your a bloody ledgend. Its sorted.

I've been a tit. That error on the last has sorted it. A mistake on my part in the mysql end. What a complete tit I am.

Thank you so much mate. You have been amazing. I'm so happy now. Thank you.

Posted: Tue May 15, 2007 4:16 pm
by toby_c500
I just hope I can return the favor one day.

Thanks again mate. I feel like a fool.

Posted: Tue May 15, 2007 4:17 pm
by guitarlvr
Hey we all make mistakes, glad you got it going. :)

Wayne