Jump to content

SugarCRM Code Help


clbryan26

Recommended Posts

I am trying to get a client account automatically created in SugarCRM when they are registered in WHMCS. I have modified the actionhooks.php file with the following code. Being that I am rather new to development and PHP can someone please point out where my problem is with the following code?

 

Everything works it tells me that "

Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/mycommon/public_html/mybill/v1/includes/actionhooks.php on line 52"

 

I have looked at my code and just can't figure it out. I also added a new field in phpmyadmin called mybillid to better reference the client account in WHMCS so that in the future I can perhaps do other functions and develop this temporary bridge further.

 

	#sugarcrm insert when created

$con = mysql_connect("localhost","username","password");
if (!$con)
 	{
 	die('Could not connect: ' . mysql_error());
 	}

mysql_select_db("mycommon_v2", $con);

mysql_query("INSERT INTO accounts ( id, name, date_entered, date_modified, modified_user_id, created_by, description, deleted, assigned_user_id, account_type, industry, annual_revenue, phone_fax, billing_address_street, billing_address_city, billing_address_state, billing_address_postalcode, billing_address_country, rating, phone_office, phone_alternate, website, ownership, employees, ticker_symbol, shipping_address_street, shipping_address_city, shipping_address_state, shipping_address_postalcode, shipping_address_country, parent_id, sic_code, campaign_id, mybillid) 
VALUES ('', '$vars["Email"]', NOW( ) , NOW( ) , NULL , NULL , NULL , '0', NULL , NULL , NULL , NULL , 'NULL', '$vars["Address1"]', '$vars["City"]', '$vars["State"]', '$vars["Postcode"]', '$vars["Country"]', NULL , '$vars["PhoneNumber"]', NULL, 'website', NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , '$vars["ClientID"]')");

 

Thanks for any help it is greatly appreciated and well noted!

Link to comment
Share on other sites

On each of the variables in your sql query that look like $vars["Address1"], change them as follows:

 

$vars["Address1"]

 

becomes

 

{$vars['Address1']}

 

Note that the quotes turned to single quotes and the entire variable is now inside curly braces. You need to do that for everything in the $vars array.

Link to comment
Share on other sites

mycommon,

 

You can debug it by placing your entire db insert line

within an ECHO statement that outputs to screen,

or, you can output to a temp file.

 

then review the output (which will be your db insert command)

and you'll quickly see what's incorrect about the db insert command.

Most likely the variables' values are not appearing as you expected they'd be.

 

trish : - )

Edited by Its Trish
typo
Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated