Jump to content

Recommended Posts

<?php
$posts = mysql_num_rows(mysql_query("SELECT * FROM phpbb_posts", $con_posts))
$users = mysql_num_rows(mysql_query("SELECT * FROM phpbb_users", $con_users))-52
?>

Parse error: syntax error, unexpected T_VARIABLE in __ on line 1

 

All the database calls are in another <?php ?> block, they worked fine until I had them call the password from another text file for security reasons.

Is there any complaint you could see in these lines?

 

Also, the two methods I tried for calling the password from the other file was to simply read it line for line and then assign it to variables, but I changed it (neither way worked) so that the variables are declared in the other file.

 

Any ideas?

 

Oh and heres the code for the other page (all the __'s are intentional ommisions, no single or double quotes were omitted)

 

<?php 
require(__);
$con_posts = mysql_connect("$ip","$un","$pw"); // these variables are from the required file
$con_users = mysql_connect("$ip","$un","$pw");
if (!$con_posts)
  {
  die('con_posts died: ' . mysql_error());
  }
if (!$con_users)
  {
  die('con_users died: ' . mysql_error());
  }

mysql_select_db("__", $con_posts);
mysql_select_db("__", $con_users);
?>

Link to comment
https://forums.phpfreaks.com/topic/109954-annoying-problem/
Share on other sites

Actually, moving those to their own line (and forgetting the semicolons) was something I did AFTER the error arose, and the error followed the query. Furthermore, it says error on line 1, semicolon errors almost always are not determined until line 2.

 

I added them, thought you were right, and I was psyched about it, but I still get:

 

Parse error: syntax error, unexpected T_VARIABLE in __ on line 1

Link to comment
https://forums.phpfreaks.com/topic/109954-annoying-problem/#findComment-564455
Share on other sites

<?php 
require(__);
$con_posts = mysql_connect("$ip","$un","$pw");
$con_users = mysql_connect("$ip","$un","$pw");

mysql_select_db("__", $con_posts);
mysql_select_db("__", $con_users);
?>

<?php
$posts = mysql_num_rows(mysql_query("SELECT * FROM phpbb_posts", $con_posts));
$users = mysql_num_rows(mysql_query("SELECT * FROM phpbb_users", $con_users))-52;
echo "Posts: <b>". $posts ."</b><br>";
echo "Users: <b>". $users ."</b>";
?>
<br>

Link to comment
https://forums.phpfreaks.com/topic/109954-annoying-problem/#findComment-564459
Share on other sites

Why are you creating two separate database connections?  Bad idea, unless you need to.

 

moreover,

 

is that really line 1?

are thsoe all the lines you have?

does that line 1 is pointing to the required php script?

 

am not getting the problem, or maybe i overlooked it myself :)

Link to comment
https://forums.phpfreaks.com/topic/109954-annoying-problem/#findComment-564467
Share on other sites

The problem is ACTUALLY in the second <?php ?> chunk.

 

If I comment out

$posts = mysql_num_rows(mysql_query("SELECT * FROM phpbb_posts", $con_posts));

$users = mysql_num_rows(mysql_query("SELECT * FROM phpbb_users", $con_users))-52;

 

they go away.

 

Also, why shouldn't I create two connections? I could just use the same connection twice I guess. Actually I'm not sure why I didn't..

Link to comment
https://forums.phpfreaks.com/topic/109954-annoying-problem/#findComment-564477
Share on other sites

PHP is on crack!

I moved the <div> that contained this broken code down below another piece of the code, and the whole page turned to an error, and then I switched it back because thats much worse, and now, the main page is STILL broken after I reverted to the old file. I am so confused.

 

:(

 

Is it possible that a bad FTP program is causing some horrid corruption? Because I have only tried 2 or 3 files, but everything I've uploaded from filezilla returns this error. I don't want to test it further/

Link to comment
https://forums.phpfreaks.com/topic/109954-annoying-problem/#findComment-564481
Share on other sites

What editor are you using to create you scripts? It's possible that the editor is inserting hidden characters in your file.

 

Ken

 

That could cause header issues (someone had that issue and I spent like, 30 minutes and 6 PMs trying to explain to them what to do, lol), but I don't think it would really cause a MySQL issue like that.  But alas, he should check out the editor to eliminate any potential problems later on.

Link to comment
https://forums.phpfreaks.com/topic/109954-annoying-problem/#findComment-564489
Share on other sites

Notepad++ or Eclipse are good as well.

 

yep... those two are nice. but if you want to have a lightweight yet better than notepad++, you may use phpdesigner2007 personal. there was 2008 version but 2007 would do.

 

how bout dissecting your code instead of nesting:

 

$posts = mysql_num_rows(mysql_query("SELECT * FROM phpbb_posts", $con_posts));
$users = mysql_num_rows(mysql_query("SELECT * FROM phpbb_users", $con_users))-52;

 

to:

 

$posts_resource = mysql_query("SELECT * FROM phpbb_posts", $con_posts);
$users_resource = mysql_query("SELECT * FROM phpbb_users", $con_users);

$posts = mysql_num_rows($posts_resource);
$users = mysql_num_rows($users_resource);
$users_deducted = $users - 52;

 

its a lot cleaner and you can see more clearly where the error really occured.

 

Link to comment
https://forums.phpfreaks.com/topic/109954-annoying-problem/#findComment-564496
Share on other sites

Heres how everything sits now.  Sadly I dont understand the error. I learned PHP and SQL two nights ago, and only learn as I go, so there is very likely a shining error. I am thinking that my attempt to connect a funny way failed? However, I can print the variables in that file no problem.

 

9   mysql_select_db("darktalon_forum", $con_posts);
10  $posts_resource = mysql_query("SELECT * FROM phpbb_posts", $con_posts);
11  mysql_select_db("darktalon_forum", $con_users);
12  $users_resource = mysql_query("SELECT * FROM phpbb_users", $con_users);
13  
14  $posts = mysql_num_rows($posts_resource);
15  $users = mysql_num_rows($users_resource) - 52;

 

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in __/html/sidebar on line 9

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in __/html/sidebar on line 10

 

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in __/html/sidebar on line 11

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in __/html/sidebar on line 12

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in __/html/sidebar on line 14

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in __/html/sidebar on line 15

Link to comment
https://forums.phpfreaks.com/topic/109954-annoying-problem/#findComment-564502
Share on other sites

1   <?php 
2   require(fubar_forum);
3   $con_forum = mysql_connect("$ip","$un","$pw");
4   if(!$con_forum)
5   {
6   	die('Cannot connect' . mysql_error());
7   }

 

I changed the name of the connection, then didnt move the change to the other parts. OMG

I am so sorry guys, every problem I have asked help for is my own stupidity.

This is why I hesitated to join this forum when I had my first batch of problems. I've become the type of coder I hate. Dependent.

 

 

THANK YOU ALL YOUR AMAZING HELP, Without the suggestion about my text editor, I would have probably just dug the site deeper and deeper into oblivion and hated PHP forever.

 

And sorry for asking help for things I should have done on my own.

Link to comment
https://forums.phpfreaks.com/topic/109954-annoying-problem/#findComment-564510
Share on other sites

do you mean to say that you managed to solve it now?

 

feel free to ask... am just new to this forum also, around 3 days? am also newbie in PHP, less than a year.

 

anyway askin is fine. but its always better to do things on our own first, do some effort on crawling the web and some research before asking.

 

lets just help each other... :)

 

cheers,

 

Jay

Link to comment
https://forums.phpfreaks.com/topic/109954-annoying-problem/#findComment-564520
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.