INSERT INTO doesn't work.[sorted at last. thanks wayne]
Moderator: General Moderators
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
Wayne
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.
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.
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.
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());
?>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());
?>