Benaravo Posted January 15, 2007 Share Posted January 15, 2007 Hey,I posted a problem with the same script yetserday, attempting to sort it out my self... I've made some changes to the sytax of the MySQL Query mainly.. If you could take a look and see if there's anything obvious I've missed, it would be greatly appriciated!The line which the error is on is 31, and also occasionally 2424: $sql = 'insert into forum values('$usr','$pwd','$name','$admin',''';31: echo( "Record Added" );[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><?php$usr = $_POST['user'];$pwd = $_POST['pass'];$name = $_POST['name'];$admin = $_POST['admin'];$conn= @mysql_connect( "localhost","ben","/200791bp" )or die( "Error, could not connect to MySQL" );$rs = @mysql_select_db( "ben_login", $conn )or die( mysql_error() );$sql = 'insert into forum values('$usr','$pwd','$name','$admin',''';$rs = mysql_query( $sql, $conn )or die(mysql_error());if($rs){echo( "Record Added" );}else{echo('Error with MySQL Connection');}?></body></html>[/code] Link to comment https://forums.phpfreaks.com/topic/34342-unexpected-t_variablestring/ Share on other sites More sharing options...
trq Posted January 15, 2007 Share Posted January 15, 2007 [code=php:0]$sql = "insert into forum values ('$usr','$pwd','$name','$admin')";[/code]Its also a bad habit not to explicitly name your fields. Your code should look more like...[code=php:0]$sql = "insert into forum (usr,pwd,`name`,admin) values('$usr','$pwd','$name','$admin')";[/code] Link to comment https://forums.phpfreaks.com/topic/34342-unexpected-t_variablestring/#findComment-161561 Share on other sites More sharing options...
Benaravo Posted January 15, 2007 Author Share Posted January 15, 2007 I did have the query syntax like that, but then looked at some tutorial and it had it without defining the fields.That appears to have fixed the script, but now I seem to have a problem with MySQL... Anyway, I'll have a look at that :P Link to comment https://forums.phpfreaks.com/topic/34342-unexpected-t_variablestring/#findComment-161566 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.