Ask a Question related to PHP Development, Design and Development.
-
Québec #1
unexpected T_STRING in (newbe)
Hi,
I am trying to fill a database mysql with php.
if (!$db){
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db("pierredata");
===================== up tohere is ok
I tried theese two lines and others
INSERT INTO `commentaires`
(`nom`,`courriel`,`sujet`,`commentaire`)VALUES('Mo i2', 'ss@eee.vv',
'Bonjour', 'test');
INSERT INTO `commentaires`
(`nom`,`courriel`,`sujet`,`commentaire`)VALUES(\"M oi2\", \"ss\@eee.vv\",
\"Bonjour\", \"test\");
I get an error
unexpected T_STRING
Jean Pierre
--
--
[url]http://web.jeanpierredaviau.com[/url]
Québec Guest
-
#40790 [NEW]: List interface parsed as T_LIST instead of T_STRING
From: markpk at gmail dot com Operating system: PHP version: 5.2.1 PHP Bug Type: Scripting Engine problem Bug description: ... -
PHP Parse error: parse error, unexpected t_string
Thanks for your advice. It was a painstaking exercise and highly frustrating not being able to start Live data. Peter Kamstra -
unexpected T_STRING problem..
hi with this function i get: function retournlisteartricle($nosection) { echo '<table>'; $requete = mysql_query("SELECT art_noarticle,... -
newbe THANKS
Thanks to all with your help were up and running and looks good ! had to reload the program from the web, my new set of disks had a beta ver of... -
parse error, unexpected T_STRING
in the line "include(sign.php);" the file name should be in quotes; like include("sign.php"); hth Kurt Milligan sky2070 wrote: -
Rocky #2
Re: unexpected T_STRING in (newbe)
In article <cX%Zc.55002$681.917031@weber.videotron.net>, [email]Once@WasEno.ugh[/email]
says...Assuming you've CREATE-d a TABLE named commentaires with 4> Hi,
>
> I am trying to fill a database mysql with php.
>
> if (!$db){
> echo "Error: Could not connect to database. Please try again later.";
> exit;
> }
> mysql_select_db("pierredata");
> ===================== up tohere is ok
> I tried theese two lines and others
>
> INSERT INTO `commentaires`
> (`nom`,`courriel`,`sujet`,`commentaire`)VALUES('Mo i2', 'ss@eee.vv',
> 'Bonjour', 'test');
> INSERT INTO `commentaires`
> (`nom`,`courriel`,`sujet`,`commentaire`)VALUES(\"M oi2\", \"ss\@eee.vv\",
> \"Bonjour\", \"test\");
>
> I get an error
>
> unexpected T_STRING
>
>
columns/fields ...
Try :
INSERT INTO commentaires VALUES('Moi2','ss@eee.vv','Bonjour','test');
Let's see the TABLE strucure as well.
Rocky
[url]http://www.rockymania.org.uk/[/url]
Rocky Guest
-
Québec #3
Re: unexpected T_STRING in (newbe)
This line has been generated by the table.
I will try your line
Jean
"Rocky" <admin@rockymania.org.uk> a écrit dans le message de
news:MPG.1ba29ef6825e241098968f@text.news.ntlworld .com...later.";> In article <cX%Zc.55002$681.917031@weber.videotron.net>, [email]Once@WasEno.ugh[/email]
> says...> > Hi,
> >
> > I am trying to fill a database mysql with php.
> >
> > if (!$db){
> > echo "Error: Could not connect to database. Please try again> Assuming you've CREATE-d a TABLE named commentaires with 4> > exit;
> > }
> > mysql_select_db("pierredata");
> > ===================== up tohere is ok
> > I tried theese two lines and others
> >
> > INSERT INTO `commentaires`
> > (`nom`,`courriel`,`sujet`,`commentaire`)VALUES('Mo i2', 'ss@eee.vv',
> > 'Bonjour', 'test');
> > INSERT INTO `commentaires`
> > (`nom`,`courriel`,`sujet`,`commentaire`)VALUES(\"M oi2\", \"ss\@eee.vv\",
> > \"Bonjour\", \"test\");
> >
> > I get an error
> >
> > unexpected T_STRING
> >
> >
> columns/fields ...
> Try :
> INSERT INTO commentaires VALUES('Moi2','ss@eee.vv','Bonjour','test');
>
> Let's see the TABLE strucure as well.
>
> Rocky
> [url]http://www.rockymania.org.uk/[/url]
Québec Guest
-
Québec #4
Re: unexpected T_STRING in (newbe)
Same problem .
# phpMyAdmin SQL Dump> > Let's see the TABLE strucure as well.
# version 2.5.3
# [url]http://www.phpmyadmin.net[/url]
#
# Serveur:
# Généré le : Vendredi 03 Septembre 2004 à 15:30
# Version du serveur: 4.0.15
# Version de PHP: 4.3.3
#
# Base de données: `pierredata`
#
# --------------------------------------------------------
#
# Structure de la table `etudiants`
#
CREATE TABLE `etudiants` (
`ID` int(11) NOT NULL auto_increment,
`courriel` char(40) NOT NULL default '',
`passe` char(15) NOT NULL default '',
`nom` char(40) NOT NULL default '',
`peinture` char(20) NOT NULL default '',
`adresse` char(70) NOT NULL default '',
`tel` char(15) NOT NULL default '',
PRIMARY KEY (`ID`)
) TYPE=MyISAM COMMENT='premiere' AUTO_INCREMENT=3 ;
#
# Contenu de la table `etudiants`
#
INSERT INTO `etudiants` VALUES (1, 'foo@foot.ca', 'qWefoo76', 'Jean Pierre
Daviau', '', '12 foo4ave Québec H1B 4N9', '51462');
Québec Guest
-
Québec #5
Re: unexpected T_STRING in (newbe)
Sorry,
=====================
# phpMyAdmin SQL Dump
# version 2.5.3
# [url]http://www.phpmyadmin.net[/url]
#
# Serveur: localhost
# Généré le : Vendredi 03 Septembre 2004 à 15:35
# Version du serveur: 4.0.15
# Version de PHP: 4.3.3
#
# Base de données: `pierredata`
#
# --------------------------------------------------------
#
# Structure de la table `commentaires`
#
CREATE TABLE `commentaires` (
`nom` varchar(45) NOT NULL default '',
`courriel` varchar(30) NOT NULL default '',
`sujet` varchar(50) NOT NULL default '',
`commentaire` mediumtext NOT NULL
) TYPE=MyISAM;
#
# Contenu de la table `commentaires`
#
INSERT INTO `commentaires` VALUES ('Jean Pierre Daviau', 'foo@foo.ca',
'Bonjour', 'Un commentaire');
Québec Guest
-
Rocky #6
Re: unexpected T_STRING in (newbe)
In article <%J3_c.61015$Vx2.956264@wagner.videotron.net>,
[email]Once@WasEno.ugh[/email] says...With a DataBase name of pierredata I ran the sql and all worked fine.> Sorry,
>
> =====================
> # phpMyAdmin SQL Dump
> # version 2.5.3
> # [url]http://www.phpmyadmin.net[/url]
> #
> # Serveur: localhost
> # Généré le : Vendredi 03 Septembre 2004 à 15:35
> # Version du serveur: 4.0.15
> # Version de PHP: 4.3.3
> #
> # Base de données: `pierredata`
> #
>
> # --------------------------------------------------------
>
> #
> # Structure de la table `commentaires`
> #
>
> CREATE TABLE `commentaires` (
> `nom` varchar(45) NOT NULL default '',
> `courriel` varchar(30) NOT NULL default '',
> `sujet` varchar(50) NOT NULL default '',
> `commentaire` mediumtext NOT NULL
> ) TYPE=MyISAM;
>
> #
> # Contenu de la table `commentaires`
> #
>
> INSERT INTO `commentaires` VALUES ('Jean Pierre Daviau', 'foo@foo.ca',
> 'Bonjour', 'Un commentaire');
>
>
Rocky
Rocky Guest
-
Québec #7
Re: unexpected T_STRING in (newbe)
Thank you. The error must be somewhere else in the code and unrelated to
that line ...
Jean
Québec Guest
-
Drizzt Do'Urden #8
Re: unexpected T_STRING in (newbe)
U¿ytkownik "Québec" <Once@WasEno.ugh> napisa³ w wiadomo¶ci
news:cX%Zc.55002$681.917031@weber.videotron.net...Did You put an sql query directly into PHP code? unexpected T_STRING is> INSERT INTO `commentaires`
> (`nom`,`courriel`,`sujet`,`commentaire`)VALUES('Mo i2', 'ss@eee.vv',
> 'Bonjour', 'test');
> INSERT INTO `commentaires`
> (`nom`,`courriel`,`sujet`,`commentaire`)VALUES(\"M oi2\", \"ss\@eee.vv\",
> \"Bonjour\", \"test\");
>
> I get an error
>
> unexpected T_STRING
probably 'INSERT' word which is not
an PHP function.:)
Look like really newbie problem :) And all replies too...LOL
Try:
mysql_query("INSERT INTO `commentaires`
(`nom`,`courriel`,`sujet`,`commentaire`)VALUES('Mo i2', 'ss@eee.vv',
'Bonjour', 'test')");
Read about:
[url]http://www.php.net/manual/en/function.mysql-query.php[/url]
Drizzt
Drizzt Do'Urden Guest
-
Québec #9
Re: unexpected T_STRING in (newbe)
I have an autoincrement ID in column 1
I have a Date in column 8
Should this work and the first and last columns taken care by mySql
automatically?
mysql_query("INSERT INTO `etudiants` (`courriel`, `passe`, `nom`, `image`,
`adresse`,`telephone`)VALUES($courrielty , $passe, $nomty, $imagety,
$addressty, $telty)");
Jean
Québec Guest
-
Drizzt Do'Urden #10
Re: unexpected T_STRING in (newbe)
U¿ytkownik "Québec" <Once@WasEno.ugh> napisa³ w wiadomo¶ci
news:cj2%c.7078$dd5.769719@weber.videotron.net...autoincrement - yes - will be do automatically> I have an autoincrement ID in column 1
> I have a Date in column 8
> Should this work and the first and last columns taken care by mySql
> automatically?
>
> mysql_query("INSERT INTO `etudiants` (`courriel`, `passe`, `nom`, `image`,
> `adresse`,`telephone`)VALUES($courrielty , $passe, $nomty, $imagety,
> $addressty, $telty)");
>
> Jean
Date - no - have to add `Date` to field list and NOW() to values list
Drizzt
Drizzt Do'Urden Guest
-
Québec #11
Re: unexpected T_STRING in (newbe)
> autoincrement - yes - will be do automatically
I took off the ID and used> Date - no - have to add `Date` to field list and NOW() to values list
mysql_query("INSERT INTO `commentaires`(`nom`, `courriel`, `sujet`,
`commentaire`, `date`) VALUES ($nom, $courriel, $sujet, $commentaire,
NOW())");
The result is printed in a html page before the variables go thrue
addslashes.
nothing is written in the table commentaires
I am using EasyPHP 1.7
Jean
-------------------php ------------
$sujet = $_REQUEST['sujet'];
$nom = $_REQUEST['nom'];
$courriel = $_REQUEST['courriel'];
$commentaire = $_REQUEST['commentaire'];
$empty = array($nom, $courriel, $sujet, $commentaire);
$empty2 = array("nom", "courriel", "sujet", "commentaire");
$j = 0;
$missing = "<p>";
while($j < 4){
if($empty[$j] == "")
$missing = $missing.$empty2[$j]."<br>";
$j++;
}
if($missing != "<p>") {
printf("Formulaire incomplet: %s <br>manquant(s).", $missing);
printf("<p><a
href='http://127.0.0.1/JeanPierreDaviau/feedback.htm'>Complétez le
formulaire.</a>");
exit;
}
$db = mysql_pconnect("localhost", "root", "secret");
if (!$db){
echo "Error: Could not connect to database. Please try again later.";
exit;
}
echo $db."<---<br>";
mysql_select_db("pierredata");
echo "<p>".$nom."<br>".$courriel."<br>".$sujet."<br>".$ commentaire."</p>";
echo "<p>merci de votre attention.</p>";
$nom = addslashes($nom);
$courriel = addslashes($courriel);
$sujet = addslashes($sujet);
$commentaire = addslashes($commentaire);
mysql_query("INSERT INTO `commentaires`(`nom`, `courriel`, `sujet`,
`commentaire`, `date`) VALUES ($nom, $courriel, $sujet, $commentaire,
NOW())");
?>
----------------
Québec Guest
-
Québec #12
Re: unexpected T_STRING in (newbe)
I get It!
variables must be in quotes '$name' etc
thanks.
Québec Guest
-
Unregistered #13
Re: unexpected T_STRING in (newbe)
I had spent hours and hours trying to get my DB to allow records to be added via Web (MySQL and PHP). Many Website searches, reading wikis and tutorials/resources later I was getting closer but still blowing it up on the add part - it would connect just fine. Your instructions above had all the answers to my syntax problems - Thanks!
Unregistered Guest



Reply With Quote


