Is this code correct?

It is supposed to get input from SMS messaging API and save it to database. Mysql database is created with Table inbox and 2 columns called ID & Msg.

I want to know if this code is going to do the job? Else help me in correcting the code.

Thanks in advance...

Regards,
Righthe.

<?php

// database
$db_host = “localhost”;
$db_user = “username”;
$db_pass = “password”;
$db_name = “database name”;

// connect to mysql
$link = mysql_pconnect ($db_host, $db_user, $db_pass) or die (“can’t connect”);
mysql_select_db ($db_name) 0or die (“can’t select database”);
$msg = trim($msg);

//input to table inbox
$sql = “INSERT INTO inbox
SET id=”,
msg=’$msg’”;
$query = mysql_query($sql) ;
?>

No, this code is not correct. While 0or seems to be a typo, the insert syntax is wrong. The id parameter is lacking a value.

Hi Smantscheff,

I have corrected those, but still i have Parse error: parse error in C:\wamp\www\index.php on line 10
$link = mysql_pconnect ($db_host, $db_user, $db_pass) or die (“can’t connect”);

I am not knowing what is the possible problem in this. Request help...

Regards,
Righthe.

Do you have a PHP or a mysql error? What is the exact error message?

Its an PHP error.

Below is the error displayed in browser

Parse error: parse error in C:\wamp\www\index.php on line 10

Problem is solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.