Jump to content

Recommended Posts

This is just a continuation of my previous post. There's an error I'm battling with. It goes thus:

 

<?php

//include("input_cl.php");

$link = mysql_connect("localhost", "root", "") or die("Could not connect");

$db = mysql_select_db("lasustaffcams", $link) or die("Could not select database");

 

 

 

addslashes($amountd)=$_POST['amountd'];

addslashes($dpt)=$_POST['department'];

addslashes($email)=$_POST['email'];

addslashes($fname) =$_POST['fname'];

addslashes($ledgerno) =$_POST['ledgerno'];

addslashes($lga)=$_POST['lga'];

addslashes($lname)=$_POST['lname'];

addslashes($nationalty)=$_POST['Nationalty'];

addslashes($oname)=$_POST['oname'];

addslashes($pfno)=$_POST['pfno'];

addslashes($residentialadd)=$_POST['residentialadd'];

addslashes($sex)=$_POST['sex'];

addslashes($soorigin)=$_POST['soorigin'];

 

//$today= date("Ymd H:i:s");

 

 

$result = mysql_query("Insert into user_table(amountd,department,email,fname,ledgerno,lga,lname,Nationalty,oname,pfno,residentialadd,sex,soorigin) values('$amountd','$department','$email','$fname','$ledgerno','$lga','$lname','$nationalty','$oname','$pfno','$residentialadd','$sex','$soorigin')") or die(mysql_error()); 

                           

if (!mysql_query($result))

  {

  die('Error: ' . mysql_error());

  }

echo "1 record added";

 

mysql_close($link)

 

?>

 

Form Variables:

 

<form action='Register_Action.php' method='post' enctype="multipart/form-data" name='register'>

  <table width='28%' border='0' align='center' cellpadding='0' cellspacing='0'>

    <tr>

      <td colspan='2'><div align='center'>

        <p><font size='2' face='verdana'>WELCOME TO LASUSTAFFCAMS Registration FORM</font></p>

        </div></td>

    </tr>

    <tr>

      <td width='31%'> </td>

      <td width='69%'> </td>

    </tr>

    <tr>

      <td colspan='2'><hr></td>

    </tr>

    <tr>

      <td height='26'><font size='2' face='verdana'>PF NO.</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='pfno'>

        </font></td>

    </tr>

    <tr>

      <td height='28'><font size='2' face='verdana'>LEDGER NO.</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='ledgerno'>

        </font></td>

    </tr>

    <tr>

      <td height='25'><font size='2' face='verdana'>FIRST NAME</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='fname'>

        </font></td>

    </tr>

  <tr>

      <td height='25'><font size='2' face='verdana'>OTHER NAMES</font><font size='2' face='verdana'></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='oname'>

        </font></td>

    </tr>

    <tr>

      <td height='25'><font size='2' face='verdana'>LAST NAME</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='lname'>

        </font></td>

    </tr>

  <tr>

      <td height='25'><font size='2' face='verdana'>STATE OF ORIGIN</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='soorigin'>

        </font></td>

    </tr>

  <tr>

      <td height='25'><font size='2' face='verdana'>LOCAL GOVERNMENT</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='lga'>

        </font></td>

    </tr>

    <tr>

      <td height='25'><font size='2' face='verdana'>NATIONALITY</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='Nationality'>

        </font></td>

    </tr>

    <tr>

      <td height='26'><font size='2' face='verdana'>Email address</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='email'>

        </font></td>

    </tr>

    <tr>

      <td height='25'><font size='2' face='verdana'>RESIDENTIAL ADDRESS</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='residentialadd' />

      </font></td>

    </tr>

    <tr>

    <td height='25'><font size='2' face='verdana'>TELEPHONE NUMBER</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='residentialadd'>

        </font></td>

    </tr>

    <tr>

      <td height='25'><font size='2' face='verdana'>DEPARTMENT</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='department' />

      </font></td>

    </tr>

    <tr>

    <td height='25'><font size='2' face='verdana'>MARITAL STATUS</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='marital'>

        </font></td>

    </tr>

    <tr>

    <td height='25'><font size='2' face='verdana'>SEX</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='sex'>

        </font></td>

    </tr>

    <tr>

  <td height='25'><font size='2' face='verdana'>AMOUNT DEDUCTIBLE</font></td>

      <td><font size='2' face='verdana'>

        <input type='text' name='amountd' />

      </font></td>

    </tr>

    <tr>

      <td> </td>

      <td><font size='2' face='verdana'>

        <input type='submit' name='Submit' value='Register'>

        </font></td>

    </tr>

    <tr>

      <td colspan='2'><hr></td>

    </tr>

    <tr>

      <td> </td>

      <td> </td>

    </tr>

  </table>

</form>

 

 

The output of this is :

"Fatal error: Can't use function return value in write context in C:\wamp\www\Cams\Register_Action.php on line 8"

 

Line 8, supposedly is:

 

the "addslashes($amountd)=$_POST['amountd'];"

 

Please I need a pointer to solve this..

 

Thanks a bunch...

Link to comment
https://forums.phpfreaks.com/topic/158123-add-slashes-error/
Share on other sites

With the add slashes function i think you want it to be formatted like this

 

$amountd = addslashes($_POST['amountd']);

 

addslashes is a function that takes a string as an argument and returns it back with backslashes before characters that need to be quoted in database queries etc. (shamelessly stolen form php.net)

 

So you can't make it = a variable, but you can make a variable = to what it returns. Which is what I imagen you want to do.

 

Oh and on another not they seem to recommend using DBMS specific escape function ie. mysqli_real_eascape_string().

 

you can read more on : http://www.php.net/addslashes

Link to comment
https://forums.phpfreaks.com/topic/158123-add-slashes-error/#findComment-834058
Share on other sites

With the add slashes function i think you want it to be formatted like this

 

$amountd = addslashes($_POST['amountd']);

 

addslashes is a function that takes a string as an argument and returns it back with backslashes before characters that need to be quoted in database queries etc. (shamelessly stolen form php.net)

 

So you can't make it = a variable, but you can make a variable = to what it returns. Which is what I imagen you want to do.

 

Oh and on another not they seem to recommend using DBMS specific escape function ie. mysqli_real_eascape_string().

 

you can read more on : http://www.php.net/addslashes

Sir, I have done as you said here's my Register_Action.php

 

<?php

//include("input_cl.php");

$link = mysql_connect("localhost", "root", "") or die("Could not connect");

$db = mysql_select_db("staffcams", $link) or die("Could not select database");

 

 

 

$amountd = addslashes($_POST['amountd']);

$dpt=addslashes($_POST['department']);

$email=addslashes($_POST['email']);

$fname =addslashes($_POST['fname']);

$ledgerno =addslashes($_POST['ledgerno']);

$lga=addslashes($_POST['lga']);

$lname=addslashes($_POST['lname']);

$nationalty=addslashes($_POST['Nationalty']);

$oname=addslashes($_POST['oname']);

$pfno=addslashes($_POST['pfno']);

$residentialadd=addslashes($_POST['residentialadd']);

$sex=addslashes($_POST['sex']);

$soorigin=addslashes($_POST['soorigin']);

 

//$today= date("Ymd H:i:s");

 

 

$result = mysql_query("Insert into user_table(amountd,department,email,fname,ledgerno,lga,lname,Nationalty,oname,pfno,residentialadd,sex,soorigin) values('$amountd','$department','$email','$fname','$ledgerno','$lga','$lname','$nationalty','$oname','$pfno','$residentialadd','$sex','$soorigin')") or die(mysql_error()); 

                           

if (!mysql_query($result))

  {

  die('Error: ' . mysql_error());

  }

echo "1 record added";

 

mysql_close($link)

                               

                                                       

?>

 

Her's the new error output:

 

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 '1' at line 1

 

What's next?

Link to comment
https://forums.phpfreaks.com/topic/158123-add-slashes-error/#findComment-834067
Share on other sites

ijust told you ion your previouse post bredrin -

 

 

$result = mysql_query("Insert into user_table(amountd,department,email,fname,ledgerno,lga,lname,Nationalty,oname,pfno,residentialadd,sex,soorigin) values('$amountd','$department','$email','$fname','$ledgerno','$lga','$lname','$nationalty','$oname','$pfno','$residentialadd','$sex','$soorigin')") or die(mysql_error());

                               

if (!mysql_query($result))

 

wrong

 

 

 

$sql= "Insert into user_table(amountd,department,email,fname,ledgerno,lga,lname,Nationalty,oname,pfno,residentialadd,sex,soorigin) values('$amountd','$department','$email','$fname','$ledgerno','$lga','$lname','$nationalty','$oname','$pfno','$residentialadd','$sex','$soorigin')";

                               

if (!mysql_query($sql))

 

correct

Link to comment
https://forums.phpfreaks.com/topic/158123-add-slashes-error/#findComment-834071
Share on other sites

ijust told you ion your previouse post bredrin -

 

 

$result = mysql_query("Insert into user_table(amountd,department,email,fname,ledgerno,lga,lname,Nationalty,oname,pfno,residentialadd,sex,soorigin) values('$amountd','$department','$email','$fname','$ledgerno','$lga','$lname','$nationalty','$oname','$pfno','$residentialadd','$sex','$soorigin')") or die(mysql_error());

                               

if (!mysql_query($result))

 

wrong

 

 

 

$sql= "Insert into user_table(amountd,department,email,fname,ledgerno,lga,lname,Nationalty,oname,pfno,residentialadd,sex,soorigin) values('$amountd','$department','$email','$fname','$ledgerno','$lga','$lname','$nationalty','$oname','$pfno','$residentialadd','$sex','$soorigin')";

                               

if (!mysql_query($sql))

 

correct

 

Nad, I wish you would run this stuff yourself and see. I did as you said but its still hanging out:

 

Here's my Register_Action.php script:

 

<?php
//include("input_cl.php"); 
$link = mysql_connect("localhost", "root", "") or die("Could not connect");
$db = mysql_select_db("lasustaffcams", $link) or die("Could not select database");



$amountd = addslashes($_POST['amountd']);
$dpt=addslashes($_POST['department']);
$email=addslashes($_POST['email']);
$fname =addslashes($_POST['fname']);
$ledgerno =addslashes($_POST['ledgerno']);
$lga=addslashes($_POST['lga']);
$lname=addslashes($_POST['lname']);
$nationalty=addslashes($_POST['Nationalty']);
$oname=addslashes($_POST['oname']);
$pfno=addslashes($_POST['pfno']);
$residentialadd=addslashes($_POST['residentialadd']);
$sex=addslashes($_POST['sex']);
$soorigin=addslashes($_POST['soorigin']);

//$today= date("Ymd H:i:s");			


$sql = mysql_query("Insert into user_table(amountd,department,email,fname,ledgerno,lga,lname,Nationalty,oname,pfno,residentialadd,sex,soorigin) values('$amountd','$department','$email','$fname','$ledgerno','$lga','$lname','$nationalty','$oname','$pfno','$residentialadd','$sex','$soorigin')") or die(mysql_error());  
	                            
if (!mysql_query($sql))
{
  die('Error: ' . mysql_error()."  SQL: ".$sql);
  }
echo "1 record added";
?>

                                 
                                                         
?>

Link to comment
https://forums.phpfreaks.com/topic/158123-add-slashes-error/#findComment-834078
Share on other sites

yo you did it worng look at your other post, dont mock me man

 

Stop being a jerk if you want to help. If he bothers you, stop replying to his posts. Simple as that. Thanks.

 

i just wrote a whole essay for him on his other post thats why im bothered he completly disregarded it wrote teh wrong code then said mr nadeem code guru ur wrong , thats a waste of my time in return for help ??? i regard that as a insult, i only get a few minuits every now and then to come here and help.

Link to comment
https://forums.phpfreaks.com/topic/158123-add-slashes-error/#findComment-834092
Share on other sites

i just wrote a whole essay for him on his other post thats why im bothered he completly disregarded it wrote teh wrong code then said mr nadeem code guru ur wrong , thats a waste of my time in return for help ??? i regard that as a insult, i only get a few minuits every now and then to come here and help.

 

Learn to ignore him then. You do not have to reply to his threads. I am sure he would be grateful for you to ignore his posts as well. It is a win-win situation.

 

If you cannot say anything nice, then do not say anything at all.  Simple.

Link to comment
https://forums.phpfreaks.com/topic/158123-add-slashes-error/#findComment-834096
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.