Jump to content

[SOLVED] BEH!!!


prcollin

Recommended Posts

<?php

$host="localhost";
$user="fixxxxxr_xxxxxxn";
$passwd="nxxxxxx";
$database="fxxxxxx_xxxxx";

$con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not 

connect:".mysql_error());

mysql_select_db("findzer_Users", $con);

$sql= "insert into newuser ("user_name", "user_pass", "full_name", "user_email", 

"confirm_email", "alt_email", "user_city") 

Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use

r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']} 

Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use

r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']}";

if (!mysql_query($sql,$con))
{
die("Error:  ". mysql_error());
}

echo "1 record added";
mysql_close($con)
?>

 

Getting error

 

Parse error: syntax error, unexpected T_STRING in /home/findzer/public_html/philsshit/login.php on line 12

 

I had all the values in the "insert into" part in single quotes and got error

 

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''user_name', 'user_pass', 'full_name', 'user_email', 'confirm_email', 'alt_email' at line 1

 

so what is my problem?

Link to comment
Share on other sites

So clearly you forgot to change a ". >_>

 

this is what i have now for code and gettingthe error

 

<?php

$host="localhost";
$user="fxxxxxxr_pxxxxx";
$passwd="nxxxxxxxx";
$database="fixxxxr_Uxxxx";

$con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not 

connect:".mysql_error());

mysql_select_db("findzer_Users", $con);

$sql= "insert into newuser ('user_name', 'user_pass', 'full_name', 'user_email', 

'confirm_email', 'alt_email', 'user_city') 

Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use

r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']} 

Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use

r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']}";

if (!mysql_query($sql,$con))
{
die("Error:  ". mysql_error());
}

echo "1 record added";
mysql_close($con)
?>

Link to comment
Share on other sites

fixed version (syntatically speaking...)

<?php

$host="localhost";
$user="fixxxxxr_xxxxxxn";
$passwd="nxxxxxx";
$database="fxxxxxx_xxxxx";

$con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not 

connect:".mysql_error());

mysql_select_db("findzer_Users", $con);

$sql= "insert into newuser (`user_name`, `user_pass`, `full_name`, `user_email`, 

`confirm_email`, `alt_email`, `user_city`) 

Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use

r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']} 

Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use

r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']}";

if (!mysql_query($sql,$con))
{
die("Error:  ". mysql_error());
}

echo "1 record added";
mysql_close($con)
?>

Link to comment
Share on other sites

Still not correct.

<?php

$host="localhost";
$user="fixxxxxr_xxxxxxn";
$passwd="nxxxxxx";
$database="fxxxxxx_xxxxx";

$con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not 

connect:".mysql_error());

mysql_select_db("findzer_Users", $con);

$sql= "insert into newuser (`user_name`, `user_pass`, `full_name`, `user_email`, 

`confirm_email`, `alt_email`, `user_city`) Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use

r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']}'";

if (!mysql_query($sql,$con))
{
die("Error:  ". mysql_error());
}

echo "1 record added";
mysql_close($con)
?>

 

And you used VALUES twice.

Link to comment
Share on other sites

first half of an insert, you don't use any quotes, or if you do, you use "con ascento" (which is the key with the tilda on it, above the tab key). I didn't change your code, except to remove double quotes. YOU used value twice.

Fixed code:

<?php

$host="localhost";
$user="fixxxxxr_xxxxxxn";
$passwd="nxxxxxx";
$database="fxxxxxx_xxxxx";

$con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not 

connect:".mysql_error());

mysql_select_db("findzer_Users", $con);

$sql= "insert into newuser (`user_name`, `user_pass`, `full_name`, `user_email`, 

`confirm_email`, `alt_email`, `user_city`) 

Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use

r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']}';";

if (!mysql_query($sql,$con))
{
die("Error:  ". mysql_error());
}

echo "1 record added";
mysql_close($con)
?>

Link to comment
Share on other sites

Also, does the $_post array exist? Its not a built in. Try $_POST.

 

And seriously, inserting posted vars directly into your query like that is begging for trouble. You need to escape data properly before letting it into your queries.

Link to comment
Share on other sites

fixed version (syntatically speaking...)

<?php

$host="localhost";
$user="fixxxxxr_xxxxxxn";
$passwd="nxxxxxx";
$database="fxxxxxx_xxxxx";

$con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not 

connect:".mysql_error());

mysql_select_db("findzer_Users", $con);

$sql= "insert into newuser (`user_name`, `user_pass`, `full_name`, `user_email`, 

`confirm_email`, `alt_email`, `user_city`) 

Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use

r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']} 

Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use

r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']}";

if (!mysql_query($sql,$con))
{
die("Error:  ". mysql_error());
}

echo "1 record added";
mysql_close($con)
?>

 

Now i get

 

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5

Link to comment
Share on other sites

not fixed: here's the fixed:

<?php

$host="localhost";
$user="fixxxxxr_xxxxxxn";
$passwd="nxxxxxx";
$database="fxxxxxx_xxxxx";

$con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not 

connect:".mysql_error());

mysql_select_db("findzer_Users", $con);

$sql= "insert into newuser (`user_name`, `user_pass`, `full_name`, `user_email`, 

`confirm_email`, `alt_email`, `user_city`) 

Values('{$_POST['user_name']}','{$_POST['user_pass']}','{$_POST['full_name']}','{$_POST['user_email']}','{$_POST['confir_memail']}','{$_POST['alt_email']}','{$_POST['user_city']}';";

if (!mysql_query($sql,$con))
{
die("Error:  ". mysql_error());
}

echo "1 record added";
mysql_close($con)
?>

Link to comment
Share on other sites

Stop using Values twice and use my code.  Try it at least.

 

Its not used twice inthe ocde i dont know why it keeps showing up twice on here.  

 

with your code i get

 

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3

 

 

Link to comment
Share on other sites

Or at least read what has been said 3 times now.

 

Ive tried all their codes i dont know what it keeps givign the " error I tried switching out for ' and tried everything else i have found on the forums that I have read so far to try to elim this error.  LOL sorry i just do know the error correcting yet very well.

Link to comment
Share on other sites

found the problem

<?php

$host="localhost";
$user="fixxxxxr_xxxxxxn";
$passwd="nxxxxxx";
$database="fxxxxxx_xxxxx";

$con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not 

connect:".mysql_error());

mysql_select_db("findzer_Users", $con);

$sql= "insert into newuser (`user_name`, `user_pass`, `full_name`, `user_email`, `confirm_email`, `alt_email`, `user_city`) Values('{$_POST['user_name']}','{$_POST['user_pass']}','{$_POST['full_name']}','{$_POST['user_email']}','{$_POST['confirm_email']}','{$_POST['alt_email']}','{$_POST['user_city']}');";

if (!mysql_query($sql,$con))
{
die("Error:  ". mysql_error());
}

echo "1 record added";
mysql_close($con)
?>

Link to comment
Share on other sites

Ok that worked!!!

 

Now another problem.  When the user enters values and clicks submit and I go to phpmyadmin it shows entries added (Primary key value increases ) but no values are in the corresponding columns any idea?  probably just a clerical error?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.