Jump to content

Recommended Posts

Hi,

 

I am try to insert the following data into a database but I keep getting the following error 

Here is the code

 

<?php

mysql_query="INSERT INTO table (JobTitle, Company, Salary,Description,CompanyURL,PhoneNumber,Requirements,JobCategory,JobType,Address)

VALUES ('$Job-Title', '$Company','$Salary','$Description','$Company-URL', '$Phone-Number','$Requirements','$Job-Category','$Job-Type','$Address')");

?>

 

Here is the error message

 

Parse error: syntax error, unexpected '=' in /home/content/h/Database.php on line 60

 

Link to comment
https://forums.phpfreaks.com/topic/242416-problems-inserting-data-into-database/
Share on other sites

Your syntax is incorrect.

 

<?php
$res = mysql_query("INSERT INTO table (JobTitle, Company, Salary,Description,CompanyURL,PhoneNumber,Requirements,JobCategory,JobType,Address) VALUES (
			'".mysql_real_escape_string($Job-Title)."', 
			'".mysql_real_escape_string($Company)."',
			'".mysql_real_escape_string($Salary)."',
			'".mysql_real_escape_string($Description)."',
			'".mysql_real_escape_string($Company-URL)."', 
			'".mysql_real_escape_string($Phone-Number)."',
			'".mysql_real_escape_string($Requirements)."',
			'".mysql_real_escape_string($Job-Category)."',
			'".mysql_real_escape_string($Job-Type)."',
			'".mysql_real_escape_string($Address)."')");
?>

 

 

Hi,

 

Here is a little more of the code if it helps.

 

 

<?php echo $_SESSION['Job-Title'];?><br>

<?php echo $_SESSION['Company'];?><br>

<?php echo $_SESSION['Salary'];?><br>

<?php echo $_SESSION['Description'];?><br>

<?php echo $_SESSION['Company-URL'];?><br>

<?php echo $_SESSION['Phone-Number'];?><br>

<?php echo $_SESSION['Address'];?><br>

<?php echo $_SESSION['Requirements'];?><br>

<?php echo $_SESSION['Job-Type'];?><br>

<?php echo $_SESSION['Job-Category'];?><br>

 

<br><br>

<br><br>

 

<?php

 

// assigning variables the session variables

 

$Job-Title    =$_SESSION['Job-Title'];

$Company      =$_SESSION['Company'];

$Salary      =$_SESSION['Salary'];

$Description  =$_SESSION['Description'];

$Company-URL  =$_SESSION['Company-URL'];

$Phone-Number =$_SESSION['Phone-Number'];

$Requirements =$_SESSION['Requirements'];

$Job-Category =$_SESSION['Job-Category'];

$Job-Type    =$_SESSION['Job-Type'];

$Address      =$_SESSION['Address'];

 

?>

 

 

 

<?php

include'../DB-Connect.php';

 

 

 

// Insert a row of information into the table "Table"

 

$res = mysql_query("INSERT INTO Table (JobTitle, Company, Salary,Description,CompanyURL,PhoneNumber,Requirements,JobCategory,JobType,Address)

VALUES ('".mysql_real_escape_string($Job-Title)."',

'".mysql_real_escape_string($Company)."',

'".mysql_real_escape_string($Salary)."',

'".mysql_real_escape_string($Description)."',

'".mysql_real_escape_string($Company-URL)."',

'".mysql_real_escape_string($Phone-Number)."',

'".mysql_real_escape_string($Requirements)."',

'".mysql_real_escape_string($Job-Category)."',

'".mysql_real_escape_string($Job-Type)."',

'".mysql_real_escape_string($Address)."')");

 

 

?>

Please add code tags around your code when you submit a post (the code button is in the editor window). I cannot read it clearly as plain text. What exactly is on line 60? The code I posted is correct. Are you sure that it has been uploaded if you are getting the same error? I can see that your original code would have given that error so that's why I am suspect.

Hi here is some more of the code

 





<?php echo $_SESSION['Job-Title'];?><br>
<?php echo $_SESSION['Company'];?><br>
<?php echo $_SESSION['Salary'];?><br>
<?php echo $_SESSION['Description'];?><br>
<?php echo $_SESSION['Company-URL'];?><br>
<?php echo $_SESSION['Phone-Number'];?><br>
<?php echo $_SESSION['Address'];?><br>
<?php echo $_SESSION['Requirements'];?><br>
<?php echo $_SESSION['Job-Type'];?><br>
<?php echo $_SESSION['Job-Category'];?><br>

<br><br>
<br><br>

<?php

// assigning variables the session variables 

$Job-Title    =$_SESSION['Job-Title'];
$Company      =$_SESSION['Company'];
$Salary       =$_SESSION['Salary'];
$Description  =$_SESSION['Description'];
$Company-URL  =$_SESSION['Company-URL'];
$Phone-Number =$_SESSION['Phone-Number'];
$Requirements =$_SESSION['Requirements'];
$Job-Category =$_SESSION['Job-Category'];
$Job-Type     =$_SESSION['Job-Type'];
$Address      =$_SESSION['Address'];

?>



<?php
include'../DB-Connect.php';



// Insert a row of information into the table "Table"

$res = mysql_query("INSERT INTO Table (JobTitle, Company, Salary,Description,CompanyURL,PhoneNumber,Requirements,JobCategory,JobType,Address)
VALUES ('".mysql_real_escape_string($Job-Title)."',
    '".mysql_real_escape_string($Company)."',
   '".mysql_real_escape_string($Salary)."',
   '".mysql_real_escape_string($Description)."',
   '".mysql_real_escape_string($Company-URL)."',
    '".mysql_real_escape_string($Phone-Number)."',
   '".mysql_real_escape_string($Requirements)."',
   '".mysql_real_escape_string($Job-Category)."',
   '".mysql_real_escape_string($Job-Type)."',
   '".mysql_real_escape_string($Address)."')");


?> 




Posted by: jobs1109
« on: Today at 06:04:29 AM »Insert Quote







 

 

 

 

Posted by: jobs1109

« on: Today at 06:04:29 AM »Insert Quote

 

 

I want to SEE line 60! The error is on line 60. You must read the errors!

 

Parse error: syntax error, unexpected '=' in /home/content/h/i/l/hilo101/html/Hilo-Jobs/Post-Jobs-to-Database/Post-Jobs-to-Database.php on line 60

 

Post DB-Connect.php also. However make sure you remove the username & password details for your database connection before posting.

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.