Web Hosting Talk







View Full Version : PHP Problem


RoyalDesigns
06-26-2008, 10:37 PM
When I tried to put the script on my index.php page, I get an error looking like this:

Parse error: syntax error, unexpected T_STRING in /home/digitial/public_html/index.php on line 22


This is line 22, is there something wrong?:

$get=mysql_query("SELECT count(id) FROM login WHERE user='$user' and pass='$pass");


Also, I'm not really good at FTP...so is it bad to use the file manager on the cPanel? If not, where do I go to upload an image on the main index page?

Thanks.

PNH-Madih
06-26-2008, 11:07 PM
It will be like this:

$get=mysql_query("SELECT count(id) FROM login WHERE user='$user' and pass='$pass'");

The coma was missing after $pass in your coding.

PNH-Madih
06-26-2008, 11:10 PM
Also, I'm not really good at FTP...so is it bad to use the file manager on the cPanel? If not, where do I go to upload an image on the main index page?

By using FTP it is very easy to uplaod.

Just use some ftp client and uplaod your pages.

BurakUeda
06-26-2008, 11:26 PM
I think you didn't put a semi-colon at the end of line 21?
paynhost is right about your SQL string, but that will throw a MySQL error, not a PHP error.

RoyalDesigns
06-26-2008, 11:28 PM
Thanks, right now I'm using 'File Manager' on the cPanel....but see I added the extra comma there but it still gives me the error. But when I use the HTML editor it provides on cPanel the actual scripts works...doesn't make sense right?

There's a space for line 21. Between line 20, and 22 there's nothing but a space.

stanosf
06-26-2008, 11:29 PM
It will be like this:

$get=mysql_query("SELECT count(id) FROM login WHERE user='$user' and pass='$pass'");

The coma was missing after $pass in your coding.

in case it is not clear from the text, it is a closing single quote that paynhost is referring to.

RoyalDesigns
06-26-2008, 11:35 PM
I tried that, still no good...

BurakUeda
06-26-2008, 11:36 PM
If line 21 is empty, go to the non-empty line before 22 and check the semi-colon or other syntax error. Or better, just post that line here too.

RoyalDesigns
06-26-2008, 11:45 PM
mysql_select_db('login');

$get=mysql_query("SELECT count(id) FROM login WHERE user='$user' and pass='$pass");


That's line 20,21,22.

21 is an empty space. See any problems?

BurakUeda
06-26-2008, 11:56 PM
Seems normal to me.
Never used cPanel's file manager but probably it escapes the quotes when saving to server?

You really should use a FTP client to upload your code.
Like FileZilla (http://filezilla-project.org/), ALFTP (http://www.altools.com/ALTools/ALFTP.aspx)

And you should fix your SQL string as paynhost said, or you will not get anything from database.

RoyalDesigns
06-27-2008, 12:05 AM
I got CoffeeCup FTP, is that good?
And, what error do you see with my SQL string?

Also,

I know what's wrong I think, my script is called cookielogin.html, I was making the page called index.php, it wasn't working.
So, I just made the extension cookielogin.html, but when I renamed the file to index.php it still doesn't work...

RoyalDesigns
06-27-2008, 12:35 AM
Ah! I found the problem, the extension has to be HTML? Why is that? "Index.html" works but "Index.php" doesn't?

Codebird
06-27-2008, 02:47 AM
$get=mysql_query("SELECT count(id) FROM login WHERE user='$user' and pass='$pass ' ");


you see the bold thing at the end of the query that is your problem put a single quote before the double quotes.


and as ftp client you can just use fireftp (firefox extension)

PNH-Madih
06-27-2008, 05:10 AM
$get=mysql_query("SELECT count(id) FROM login WHERE user='$user' and pass='$pass ' ");


you see the bold thing at the end of the query that is your problem put a single quote before the double quotes.


and as ftp client you can just use fireftp (firefox extension)


I told the same thing by giving the first reply.

rankris
06-27-2008, 06:07 AM
hmm seems like im also with the same pb:(

Codebird
06-27-2008, 06:12 AM
I told the same thing by giving the first reply.

I know but seems like he's not seeing it or something I don't know

greg2007
06-28-2008, 03:13 PM
$get=mysql_query("SELECT count(id) FROM login WHERE user='$user' and pass='$pass");

As said a few times, even before you posted that, you don't close your quotes correctly.
You have a double quote " as required before the SELECT, and also after the $pass you have the " to close and wrap that whole statement

But you open the $pass with the single quote ' and then dont close $pass with the single quote '


Ah! I found the problem, the extension has to be HTML? Why is that? "Index.html" works but "Index.php" doesn't?
hmlt file extention wont run php code in it.
It will be expecting html and nothing else, so will output any php as text (unless there is a tag of some kind amongst it)
To run PHP code you have to use a .php file extention (or use a .htaccess file to change it, but thats something else)