By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

unexpected T_VARIABLE, expecting '{'

P: 7
Someone please see what the problem is.. I have getting an error: Parse error: syntax error, unexpected T_VARIABLE, expecting '{' in /customers/test-dig.dk/test-dig.dk/httpd.www/database.inc.php on line 3

my php codes are:

Expand|Select|Wrap|Line Numbers
  1.  <? 
  2. function connectDatabase()
  3.     $connect=mysql_connect("test_dig_dk", "test_dig_dk", "myusercode");
  4.     $select=mysql_select_db("ib",$connect);
  5.     if(!$connect || !$select)
  6.     {
  7.         ?>
  8.         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  9.         <html xmlns="http://www.w3.org/1999/xhtml">
  10.         <head>
  11.         <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  12.         <title>Fehler beim Verbinden mit der Datenbank</title>
  13.         </head>
  14.         <body>
  15.         <p>Es ist beim Verbinden mit der Datenbank ein Fehler aufgetreten!</p>
  16.         </body>
  17.         </html>
  18.         <?
  19.         exit();
  20.     }
  21. }
  22. ?>
  23.  
Jul 10 '07 #1
Share this Question
Share on Google+
10 Replies


ak1dnar
Expert 100+
P: 1,584
Hi kilo,
Welcome to TSDN.

Mr.Php is expecting '{'
So put it there as he said.

Expand|Select|Wrap|Line Numbers
  1. function connectDatabase()
  2. {
  3.  
I have some doubts with your script anyway. Are you trying to connect to mySQL DB?

Thanks,
-Ajaxrand
Jul 10 '07 #2

ak1dnar
Expert 100+
P: 1,584
This might usefull to you, for your next post.
[code] tags

This time I made the job for you! :)

Thanks!
-Ajaxrand
Jul 10 '07 #3

pbmods
Expert 5K+
P: 5,821
Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as, 'please help' actually get FEWER responses?).
Jul 10 '07 #4

P: 7
That did help.. { ??... Thank you very much.
Jul 10 '07 #5

P: 7
Hi kilo,
Welcome to TSDN.

Mr.Php is expecting '{'
So put it there as he said.

Expand|Select|Wrap|Line Numbers
  1. function connectDatabase()
  2. {
  3.  
I have some doubts with your script anyway. Are you trying to connect to mySQL DB?

Thanks,
-Ajaxrand
Hi ajaxrand. Yes?? I think so...
It's a program that I payed for, to help people to read and write Danish. the program should make the dictations and save it to a database, were people can
load them. The main frame of the php is database.inc.php were all php tools use to make a connections to DB to save and upload...
If you can make this happen that all my php's are working. I have no problem discuse your payment for your help.
Jul 10 '07 #6

ak1dnar
Expert 100+
P: 1,584
Hi ajaxrand. Yes?? I think so...
It's a program that I payed for, to help people to read and write Danish. the program should make the dictations and save it to a database, were people can
load them. The main frame of the php is database.inc.php were all php tools use to make a connections to DB to save and upload...
If you can make this happen that all my php's are working. I have no problem discuse your payment for your help.
Hi Kilo,

The Scripts Developer Network is a free forum and Community members are ready to help you Free of Charge.

If you paid for the softtware tool you have the rights to fix it up from themselves.

Any way your Problem is still unclear for me.What is not working part of your script.

Thanks :)
Jul 11 '07 #7

P: 7
I having small proplems. I think. I've getting some errors 3 at all....

If we can take one at the time.

One of them are: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /customers/test-dig.dk/test-dig.dk/httpd.www/ib/select_audio.php on line 27

The php code are:

Expand|Select|Wrap|Line Numbers
  1. <?
  2.     require("database.inc.php");
  3. {    connectDatabase();
  4. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  8. <title>V&aelig;lg lyd til <?=$_POST['title']?></title>
  9. <link href="style.css" rel="stylesheet" type="text/css" />
  10. </head>
  11.  
  12. <body>
  13. <? if(file_exists("text/".$_POST['title'].".txt")) {
  14. ?>
  15. <h1>V&aelig;lg lyd</h1>
  16. <h3 style="color:#CC3333">Pas p&aring;! Der findes allerede et diktat med denne titel.<br />
  17. Hvis du er ved at lave et nyt diktat, burde du g&aring; <a href="javascript:history.back()">tilbage</a> og v&aelig;lge en anden titel.
  18. G&oslash;r du ikke det, bliver diktatet med titelen &quot;<?=$_POST['title']?>&quot; erstattet med dette diktat her!</h3>
  19. <?
  20. }
  21. ?>
  22. <form enctype="multipart/form-data" action="save_dict.php" method="post">
  23. <input type="hidden" name="MAX_FILE_SIZE" value="500000" />
  24. <table border="0">
  25. <?
  26.     $result=mysql_query("SELECT word FROM repository;");
  27.     while($entry=mysql_fetch_array($result)) {
  28.         $repository[]=$entry[0];
  29.     }
  30.     $word_start=0;
  31.     $word_stop=0;
  32.     $open=false;
  33.     $words=array();
  34.     $content=$_POST['content'];
  35.     for($i=0;$i<strlen($content);$i++) {
  36.         if(substr($content,$i,1)=="<" && !$open) {
  37.             $word_start=$i+1;
  38.             $open=true;
  39.         }
  40.         elseif(substr($content,$i,1)==">" && $open) {
  41.             $word_stop=$i;
  42.             $word=substr($content,$word_start,$word_stop-$word_start);
  43.             if(!in_array($word,$repository)) {
  44.                 $words[]=$word;
  45.                 ?>
  46.                 <tr>
  47.                     <td><?=$word?></td>
  48.                     <td><input type="file" name="<?=$word?>" /></td>
  49.                 </tr>
  50.                 <?
  51.             }
  52.             $open=false;
  53.         }
  54.     }
  55. ?>
  56. </table>
  57. <input type="hidden" name="words" value="<? echo implode(";",$words); ?>" />
  58. <input type="hidden" name="content" value="<?=$_POST['content']?>" />
  59. <input type="hidden" name="title" value="<?=$_POST['title']?>" />
  60. <input type="submit" value="Upload &amp; gem" />
  61. </form>
  62. </body>
  63. </html>
[Please use CODE tags when posting source code. Thanks! --pbmods]
Jul 11 '07 #8

pbmods
Expert 5K+
P: 5,821
kilo, use CODE tags around your code.

Review the REPLY GUIDELINES on the right next time you post.

Thanks!

MODERATOR
Jul 11 '07 #9

P: 7
OK. I get it now

I have spoking to the company and it has been shout down. It's only one man sitting there.. what a shame..
I hope so much that you can help me through this..

Can you see what the following error mains:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /customers/test-dig.dk/test-dig.dk/httpd.www/ib/select_audio.php on line 27

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /customers/test-dig.dk/test-dig.dk/httpd.www/ib/select_audio.php on line 43

PHP code:

Expand|Select|Wrap|Line Numbers
  1. <?
  2.     require("database.inc.php");
  3.     connectDatabase();
  4. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  8. <title>V&aelig;lg lyd til <?=$_POST['title']?></title>
  9. <link href="style.css" rel="stylesheet" type="text/css" />
  10. </head>
  11.  
  12. <body>
  13. <? if(file_exists("text/".$_POST['title'].".txt")) {
  14. ?>
  15. <h1>V&aelig;lg lyd</h1>
  16. <h3 style="color:#CC3333">Pas p&aring;! Der findes allerede et diktat med denne titel.<br />
  17. Hvis du er ved at lave et nyt diktat, burde du g&aring; <a href="javascript:history.back()">tilbage</a> og v&aelig;lge en anden titel.
  18. G&oslash;r du ikke det, bliver diktatet med titelen &quot;<?=$_POST['title']?>&quot; erstattet med dette diktat her!</h3>
  19. <?
  20. }
  21. ?>
  22. <form enctype="multipart/form-data" action="save_dict.php" method="post">
  23. <input type="hidden" name="MAX_FILE_SIZE" value="500000" />
  24. <table border="0">
  25. <?
  26.     $result=mysql_query("SELECT word FROM repository;");
  27.     while($entry=mysql_fetch_array($result)) {
  28.         $repository[]=$entry[0];
  29.     }
  30.     $word_start=0;
  31.     $word_stop=0;
  32.     $open=false;
  33.     $words=array();
  34.     $content=$_POST['content'];
  35.     for($i=0;$i<strlen($content);$i++) {
  36.         if(substr($content,$i,1)=="<" && !$open) {
  37.             $word_start=$i+1;
  38.             $open=true;
  39.         }
  40.         elseif(substr($content,$i,1)==">" && $open) {
  41.             $word_stop=$i;
  42.             $word=substr($content,$word_start,$word_stop-$word_start);
  43.             if(!in_array($word,$repository)) {
  44.                 $words[]=$word;
  45.                 ?>
  46.                 <tr>
  47.                     <td><?=$word?></td>
  48.                     <td><input type="file" name="<?=$word?>" /></td>
  49.                 </tr>
  50.                 <?
  51.             }
  52.             $open=false;
  53.         }
  54.     }
  55. ?>
  56. </table>
  57. <input type="hidden" name="words" value="<? echo implode(";",$words); ?>" />
  58. <input type="hidden" name="content" value="<?=$_POST['content']?>" />
  59. <input type="hidden" name="title" value="<?=$_POST['title']?>" />
  60. <input type="submit" value="Upload &amp; gem" />
  61. </form>
  62. </body>
  63. </html>
  64.  
Jul 11 '07 #10

pbmods
Expert 5K+
P: 5,821
Heya, Kilo.

On line 27, right after you mysql_query(), add this code:
Expand|Select|Wrap|Line Numbers
  1. if(! $result)
  2.     exit(mysql_error());
  3.  
Jul 11 '07 #11

Post your reply

Sign in to post your reply or Sign up for a free account.