Can someon help with my script?

ok, i got it.

key is a reseved keyword in sql. like e.g. select.

best is not to use a field called like a reseved keyword.

an othe option that works fine as well is to surround the fieldname with ` (not a single quote but an acent)

if u cange that line to:
[php]$insert = “INSERT INTO users (username, password, email, key, verify)
VALUES (’”.$_POST[‘username’]."’, ‘".$_POST[‘pass’]."’, ‘".$_POST[‘email’]."’, ‘".$key."’)";[/php]
it will work fine

Well at least this time it was something I didn’t know any better about :slight_smile: .

good to know that it works.

if u wanna link to this side u may use:

<a href="http://phphelp.com/" target="_blank"><img src="http://phphelp.com/forums/templates/newSilver/images/logo_phpBB.gif" border="0" alt="phphelp.com" width="180" height="48"></a>

if u need a different size u have to ask peg110.

P.S.: if u gonna post some more php-code put it inside [php] instead of [code]

That size should be fine, I will be putting it on my 3 other sites as well so perhaps traffic will increase! I am trying to write a registration program (you fixed it for me) that will verify that someone is using the same name as they are in the game second life because it will interact with several communication programs I plan to launch, and I don’t want someone pretending to be someone else. I have moved to the verification part, and I have the in world program wrote so it sends the owners name of te verification device to the php and the php converts it to key then compares it, that way it can not be fooled without inside knowledge here is an example URL
http://www.sltrinkets.com/pro/pro.php?d … %20Kamachi
Thats a dead link on purpose. Heres the program that receives it

[php]

<?php $data = $_GET['data']; $key = file_get_contents('http://w-hat.com/name2key/?terse=1&name=' .urlencode( $data)); $link = mysql_connect("localhost", "protected_protected", "protected") or die('Could not connect: ' . mysql_error()); echo 'Connected successfully'; mysql_select_db("protected_protected") or die('Could not select database'); $query = mysql_query("SELECT * FROM users WHERE username = '".$data."'")or die(mysql_error()); $result = mysql_query($query) or die('Query failed: ' . mysql_error()); //find $data in the username section of the database, becuase it is a name if not found return error //if found get the key from the same line, if the key matches $key write a 1 to the verify of the same line //echo for testing purposes echo "n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "tn"; foreach ($line as $col_value) { echo "ttn"; } echo "tn"; } echo "
$col_value
n"; mysql_free_result($result); mysql_close($link); echo "success"; ?>

[/php]

Now I have not tested that it is straight from notepad, I can almost guarantee Ill be getting sql errors, if you see some point them out, but I need to know how to do something.
That should find the username and print the whole line of the database its on, I need to know how to only print the key Is that possible? Thanks!

[php]echo $line[‘key’];[/php]

P.S.: u are using notepad? have a look at weaverslave!

Looks great, thanks. The Germans always did make the best software! Unfortunately during the day Im on a MAC but ill be sure to put it on my PC a home. Im using Host monster and it has a built in PHP editor so Ill have to stick with it and notepad for the mac :(

While Im posting, can you tell me what this error means

Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Resource id #3’ at line 1

Line 1 is <?php and I dont have a clue about resource ID

wasn’t that app always called simpeltext?

u are using query twice:
[php]
$query = mysql_query(“SELECT * FROM users WHERE username = '”.$data."’")or die(mysql_error());
$result = mysql_query($query) or die('Query failed: ’ . mysql_error());
[/php]

the secont time u use it php converts the mysql result to a string wich is “Resource id #3”, and of cause trying to run “Resource id #3” as mysql-code that creates a mysql-syntax errror.

[php]
$query = “SELECT * FROM users WHERE username = '”.$data."’";
$result = mysql_query($query) or die('Query failed: ’ . mysql_error());
[/php]

edit: i had forgotten to delete the or die(mysql_error())

It may have been, Im not sure. What im using now is called text edit. The sql query I was using was a moded example, so I thought it was supposed to be like that. proved Genius once again that worked! Ill email the site I got it from and tell them they should post their work here :stuck_out_tongue: Thanks again

I LOVE THIS FORUM!

Let me ask you one last question about echo. 241affc6-98dc-4cbc-bddd-8fdc3869906a This is the value stored in the key section
241affc6-98dc-4cbc-bddd-8fdc3
869906a241affc6-98dc-4cbc-bd
dd-8fdc3869906a241affc6-98dc-4c
bc-bddd-8fdc3869906a241affc6-98dc-4
cbc-bddd-8fdc3869906a241affc6-98dc-4cb
c-bddd-8fdc3869906a241affc6-98dc-4cbc-bd
dd-8fdc3869906a
thats what it echos
and Idea why? Im posting the new script below.
I have seen /n and /t in echo, but the PHP book doesnt cover them what are they?

[php]

<?php $data = $_GET['data'];//gets the info after data= in the url and declares it $data $key = file_get_contents('http://w-hat.com/name2key/?terse=1&name=' .urlencode( $data)); $link = mysql_connect("localhost", "bizcards_admin", "dbase73354") or die('Could not connect: ' . mysql_error()); mysql_select_db("bizcards_database") or die('Could not select database'); $query = "SELECT * FROM users WHERE username = '".$data."'" or die(mysql_error()); $result = mysql_query($query) or die('Query failed: ' . mysql_error()); //find $data in the username section of the database, becuase it is a name if not found return error //if found get the key from the same line, if the key matches $key write a 1 to the verify of the same line while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { foreach ($line as $col_value) echo $line['key']; { } } mysql_free_result($result); mysql_close($link); ?>

[/php]
[/code]

please read the php manual about arrays. this is very important for using php.
http://www.php.net/manual/en/language.types.array.php

and try to look up evey function/control-structure u are using.
http://www.php.net/manual/en/control-st … oreach.php

u still use the loop to output all values. but in every loop u output the key. thats why the key is outputted as offen as u have fields in ur table.

cange:
[php]foreach ($line as $col_value)
echo $line[‘key’];
{
}[/php]
to:
[php]echo $line[‘key’];[/php]

That fixed that end of it! I have one more question, and then I think I will have all the bases covered in SQL (at least the ones I will need to cover) Is there a correct way to do this

[php]
$insert = “INSERT INTO users $line[‘verify’]
VALUES (’”.$verified."’)";
$add_member = mysql_query($insert) or die(mysql_error());
[/php]

Im trying to insert the varible $verified into the same line as I am working with. Im sure its probably a syntax problem or I am taking the wrong approach The whole code is below should it be needed
[php]

<?php define(NULL_KEY,"00000000-0000-0000-0000-000000000000"); $verified = "1"; $data = $_GET['data'];//gets the info after data= in the url and declares it $data $key = file_get_contents('http://w-hat.com/name2key/?terse=1&name=' .urlencode( $data)); $link = mysql_connect("localhost", "bizcards_admin", "dbase75454") or die('Could not connect: ' . mysql_error()); mysql_select_db("bizcards_database") or die('Could not select database'); $query = "SELECT * FROM users WHERE username = '".$data."'" or die(mysql_error()); $result = mysql_query($query) or die('Query failed: ' . mysql_error()); //find $data in the username section of the database, becuase it is a name if not found return error //if found get the key from the same line, if the key matches $key write a 1 to the verify of the same line if (!$result) { echo "You have not registered this name with us"; } if($key == NULL_KEY) { echo "Your name is not in the database Please contact Draco Kamachi"; } while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { if ($line['key'] != $key) { echo "NO MATCH"; //Ths is not possible } if ($line['key'] == $key) { $insert = "INSERT INTO users $line['verify'] VALUES ('".$verified."')"; $add_member = mysql_query($insert) or die(mysql_error()); echo "Account Verified"; } } mysql_free_result($result); mysql_close($link); ?>

[/php]

[php]$insert = ‘UPDATE users SET verified=1 WHERE username="’.mysql_escape_string($data).’"’;[/php]

I think I should set my signature to Wem Syntax verwechselt, k?nnen Entdeckungen es froh halten. (dont know the word for syntax) That fixed all my sql errors, I just need to figues out the final error and Ill be done with the thing. syntax error, unexpected ‘"’ in so I should just remove some " and itll work. Thanks for all your help on this!

Fixed the syntax now it returns
Call to undefined function: values() in verife.php on line 32

u removed the wrong one.

the quotes have to be balanced. try counting the single an double quotes. both has to be a even number.

origional line
[php]
VALUES (’".$verified."’)";
[/php]

The line after I removed one
[php]
VALUES (’".$verified."’);
[/php]

there balanced but I will try every one and see
And sorry for my bad greman es should have been sie :slight_smile:[/i]

if u realy wanna know it:
Wem Syntax verwechselt, k?nnen Entdeckungen es froh halten

wem is whom. has to be wer.
syntax is 100% right, same word an of cause with a capital letter.
verwechseln means mix up.
k?nnen is plural, but with wer it has to be singular.
Endekungen is the subject of this sentence and means discoveries.
es like u mentiont is sie.
froh means happy.
and halten is hold, behalten is keep.

if i would translate that back to english it would result in:
whom mixes up syntax, may discoveries hold it happy.

sorry, but that german sentence was exactly as confusion as this translation.

Cool, I was never good at german, I just knew enough to use the hacking programs they made :slight_smile: I have tried every possible combination of " I can think of, could the problem be something else?
[php]

<?php define(NULL_KEY,"00000000-0000-0000-0000-000000000000"); $verified = "1"; $data = $_GET['data'];//gets the info after data= in the url and declares it $data $key = file_get_contents('http://w-hat.com/name2key/?terse=1&name=' .urlencode( $data)); $link = mysql_connect("localhost", "ghtyrre_admin", "dbase") or die('Could not connect: ' . mysql_error()); mysql_select_db("bizcards_database") or die('Could not select database'); $query = "SELECT * FROM users WHERE username = '".$data."'" or die(mysql_error()); $result = mysql_query($query) or die('Query failed: ' . mysql_error()); //find $data in the username section of the database, becuase it is a name if not found return error //if found get the key from the same line, if the key matches $key write a 1 to the verify of the same line if (!$result) { echo "You have not registered this name with us"; } if($key == NULL_KEY) { echo "Your name is not in the database Please contact Draco Kamachi"; } while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { if ($line['key'] != $key) { echo "NO MATCH"; //how can this happen } if ($line['key'] == $key) { echo "Account Verified"; $insert = 'UPDATE `users` SET `verified`=1 WHERE `username`="'.mysql_escape_string($data).'"'; VALUES ('".$verified."'); $add_member = mysql_query($insert) or die(mysql_error()); } } mysql_free_result($result); mysql_close($link); ?>

[/php]

Here is the exact output less the file location including echos

Account Verified
Fatal error: Call to undefined function: values() in – on line 32

just delete this line:
[php]VALUES (’".$verified."’); [/php]

P.S.: plz put some blanks in the line 41affc6-98dc-4cbc-bddd-8fdc3869906a241affc6… (to avoid horizontal scrolling)

A+ Works flawlessly! I cant thank you enough!!! Thanks!!!

Sponsor our Newsletter | Privacy Policy | Terms of Service