Hi,
Decided to use MYSQL. Having an issue updating/inserting/deleting from my PHP script but I can cut and paste the SQL Query into PHPMyAdmin SQL and the commands work.
This SQL Query works from PHP MyAdmin but fails in my code:
INSERT INTO `frtplus_setup_frtpluscom519443`.`setup` (`f_upsrec`, `f_add1`, `F_add2`) VALUES ('zz', 'test address AS1 rtec 2', 'test addd AS2 rec 2 ')
Code connects to database, list f_add1 content which works but the insert does not update
<?php virtual('/Connections/bhhgh.php');
mysql_select_db($database_bhhgh, $bhhgh);
$query_Recordset1 = "SELECT * FROM setup ";
$Recordset1 = mysql_query($query_Recordset1, $bhhgh) or die(mysql_error());
// display f_add1 contents of database
while ($row = mysql_fetch_assoc($Recordset1))
{
echo $row['f_upsrec'] . " " . $row['f_add1'];
echo "<br>";
}
$mqlstring= "INSERT INTO `frtplus_setup_frtpluscom519443`.`setup` (`f_upsrec`, `f_add1`, `F_add2`) VALUES ('zz', 'test address AS1 rtec 2', 'test addd AS2 rec 2 ')";
mysqli_query($bhhgh,$mqlstring);
mysql_free_result($Recordset1);
?>
Any help would be appreciated.
Gary
PHP Code Help Please
Moderator: General Moderators
Re: PHP Code Help Please
Code: Select all
mysql_select_db($database_bhhgh, $bhhgh);Code: Select all
mysqli_query($bhhgh,$mqlstring);Re: PHP Code Help Please
Hi,
What are you saying here? I'm not getting it
What are you saying here? I'm not getting it
Re: PHP Code Help Please
I figured it out... Need to have a ; after "rec 2" but before the ')
Good
$mqlstring= "INSERT INTO `frtplus_setup_frtpluscom519443`.`setup` (`f_upsrec`, `f_add1`, `F_add2`) VALUES ('zz', 'test address AS1 rtec 2', 'test addd AS2 rec 2 ;')";
Not Good
$mqlstring= "INSERT INTO `frtplus_setup_frtpluscom519443`.`setup` (`f_upsrec`, `f_add1`, `F_add2`) VALUES ('zz', 'test address AS1 rtec 2', 'test addd AS2 rec 2 ')";
Good
$mqlstring= "INSERT INTO `frtplus_setup_frtpluscom519443`.`setup` (`f_upsrec`, `f_add1`, `F_add2`) VALUES ('zz', 'test address AS1 rtec 2', 'test addd AS2 rec 2 ;')";
Not Good
$mqlstring= "INSERT INTO `frtplus_setup_frtpluscom519443`.`setup` (`f_upsrec`, `f_add1`, `F_add2`) VALUES ('zz', 'test address AS1 rtec 2', 'test addd AS2 rec 2 ')";
-
akhilesh1010
- Forum Newbie
- Posts: 15
- Joined: Thu Aug 22, 2013 1:56 am
Re: PHP Code Help Please
Lets try this
$mqlstring="INSERT INTO 'setup' ('f_upsrec', 'f_add1', 'F_add2') VALUES ('zz', 'test address AS1 rtec 2', 'test addd AS2 rec 2 ')";
$mqlstring="INSERT INTO 'setup' ('f_upsrec', 'f_add1', 'F_add2') VALUES ('zz', 'test address AS1 rtec 2', 'test addd AS2 rec 2 ')";
Re: PHP Code Help Please
You'd want backticks around the table name, not single quotes. The biggest problem above is that he is using mysql_ and mysqli_ functions interchangeably.