i am trying to set up this db and i am getting a parse error which it says it is on line 24 i cannot see the error. help need

$sql="CREATE TABLE IF NOT EXISTS `merc_users` (
			
			`****` int not null,
			`******` varchar (250) not null,
			`*****` varchar(250) not null,
			`******` varchar(250) not null,
			`*****` varchar(250) not null,
			`******` varchar (250) not null,
			`*******` varchar(250) not null,
			`****` varchar(250) not null,
			`****` varchar(250) not null,
			`******` varchar (250) not null,
			`********` varchar(250) not null,
			`******` int not null
		)";	
		mysql_query($sql) or die (mysql_error() mysql_errno()); (line 24)

Dani AI

Generated

Brief diagnosis and context: a PHP "Parse error: unexpected T_STRING" is a PHP syntax problem, not a MySQL error. In this thread correctly identified a missing concatenation between two expressions as the immediate cause. Because a parse error prevents the interpreter from building a correct token stream, fixing that syntax issue can change which line the runtime later reports as the SQL error — which explains seeing a different line number when the die() call was altered.

Practical debugging checklist:

  • Run PHP’s syntax check (lint) or enable full error reporting so the exact parse error is shown (this quickly isolates missing operators, quotes, or braces).
  • Look for invisible characters (UTF‑8 BOM) or accidental short tags; these often shift line numbers.
  • Reduce the SQL statement to a minimal string or output it to a log to confirm balanced quotes, commas and parentheses before executing.
  • Watch for reserved words used as column names — wrap identifiers in backticks if needed.

Notes on account/db creation and safety: creating users or databases from a script requires administrative (root) privileges; many shared hosts disallow this, which is why control panels are commonly used. Never embed root credentials in web‑accessible code; if administrative SQL must run, restrict it to a secure administrative environment and remove credentials afterward.

Modern recommendations: avoid the old mysql_* extension in new projects — use mysqli or PDO with prepared statements and structured error/exception handling. Credit to for spotting the concatenation issue, and to for confirming that the control‑panel route can be an effective fallback when host permissions are limited.

Recommended Answers

All 10 Replies

mysql_query($sql) or die (mysql_error() mysql_errno());

Try this.

mysql_query($sql) or die (mysql_error(). mysql_errno());

Notice the concatenation operator .
Cheers,
Naveen

when i didint have the mysql_errno in and just the mysql_error it was saying that the error was on line 15 which was the fourth one down in the table create syntax. i got the tables set up in the end but i had to log on to the control panel to set it up.

There is nothing wrong with your create table query. The only thing that I found missing was the dot operator. Do you still have the error ? If yes, you need to post your complete code as I don't see any other errors!

i am just trying to replicate the error now i will get post my results back in a minute.

is it possible to create a new db on the server with a new user name and password without having to login to the phpmyadmin section on the control panel on the server?

i have had a look around but all the information i have found is already using a user name and passwrod to make the connection. I want to be able to create everything from the beginning. could you point me in the right direction of a good tutorial on this.

is it possible to create a new db on the server with a new user name and password without having to login to the phpmyadmin section on the control panel on the server?

You have to create a new user (and grant required permissions) using 'root' credentials.
Eg.

<?php
$con = mysql_connect("localhost","root");
mysql_select_db("test");

$query = "Create user 'naveen'@'localhost' IDENTIFIED BY 'password1'";
mysql_query($query);
$query2 = "GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO 'naveen'@'localhost'";
mysql_query($query2);

mysql_close($con);
echo mysql_connect("localhost","naveen","password1");
?>

I am sorry! I don't have a link to any good tutorial.

thanks for the reply. sorry i took so long to get back i am in the middle of creating a user guide for the email system. so if i run that code and where it says local host could i change that to the host name and it would run as intended.

Yep. It will create a user called "naveen" with password "password1" and grant SELECT,INSERT,UPDATE,DELETE permissions for that user.

commented: one of the most helpfull people i have come across +1

thanks for the reply you are also a great help

You are welcome!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.