Jump to content

Recommended Posts

I have the following code



$ifNameAlreadyExsist = "[0-9]";
//echo $newUserName[0-9];
echo $testUserName = $ifNewUserName[$ifNameAlreadyExsist]+;

 

When I run the code I get the following error

Parse error: syntax error, unexpected ';' in C:\wamp\www\new_signup.php on line

 

 

if I have the following line of code


$ifExsist = "SELECT COUNT( player_id ) FROM players WHERE player_id LIKE '$newUserName[0-9]'";

 

I get the following error:

Parse error: syntax error, unexpected '-', expecting ']' in C:\wamp\www\new_signup.php on line 138

 

Can someone help me to figure out why I am getting the error messages listed above?

Link to comment
https://forums.phpfreaks.com/topic/269651-find-the-exact-match-plus-number/
Share on other sites

echo $testUserName = $ifNewUserName[$ifNameAlreadyExsist]+;

 

Because PHP lines cannot end in a plus, the semicolon is unexpected.

 

 

$ifExsist = "SELECT COUNT( player_id ) FROM players WHERE player_id LIKE '$newUserName[0-9]'";

 

This line is valid, perhaps there's lines above it which are causing issues.

$ifExsist = "SELECT COUNT( player_id ) FROM players WHERE player_id LIKE '$newUserName[0-9]'";

The problem there is that PHP is trying to treat your $newUserName variable as an array and index into it, but it can't understand your index of 0-9. I personally have no idea what exactly you're trying to accomplish with said line. If $newUserName is an array, and you have a string index '0-9' you would use:

$ifExsist = "SELECT COUNT( player_id ) FROM players WHERE player_id LIKE '{$newUserName['0-9']}'";

 

If $newUserName is not an array but just a string, and you want that string to be followed by the string '[0-9]', you'd use:

$ifExsist = "SELECT COUNT( player_id ) FROM players WHERE player_id LIKE '{$newUserName}[0-9]'";

 

If neither of those is what you mean you'll have to explain what your end goal is.

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.