Kularian Posted February 7, 2007 Share Posted February 7, 2007 Okay, from what I understand, the concatenation operator essentially forces two things together into a string. So if you have: $hello = "Hello "."world"; It will read out as Hello world. Seems pretty simple. However, I'm having some issues with it, and I'm really not certain why. Here's my code, and we'll see if we can stop me from tearing hair out of my skull, <?php if(isset($cName) && isset($content) && isset($url)) { $db = mysql_connect(host, username, password); mysql_select_db(database,$db); $month = date('F'); $tmpName = $_FILES['content']['tmp_name']; $fileSize = $_FILES['content']['size']; $fp = fopen($tmpName, 'r'); $content = fread($fp, $fileSize); $content = addslashes($content); fclose($fp); $id = 0; $result = mysql_query("SELECT * FROM ad", $db) or die("failed"); while($row = mysql_fetch_array($result, MYSQL_BOTH)){ $id = $row[0]; $id += 1; } $id += 1 $aName = $cName . $id; $sql = "INSERT INTO ad (cName, aName, content, url, mnth, txt) VALUES ('$cName', '$aName', '$content', '$url', '$month', '$txt')"; $result = mysql_query($sql) or die(mysql_error()); print "Ad information added successfully."; }else{ print "Company name and image fields must be filled in. Please use the link below to go back and fill them in."; } ?> <br><br><br> <html> <body> Click <a href="link">here</a> to return to the index. </body> </html> the $aName = $cName . $id; appears to be the trouble. Okay, this little form stores some uploaded information into a db. Not too tricky. Anyway, I wanted these to be identified with a number for easier indexing. So I set $id to zero, and then run through the rows in my db, each time setting the identifier to $id, and then adding 1. This was so, to my mind, the first time it ran, it would skip over the while loop, as their would be no rows, and append a 1 onto the end. Afterward, it would read the identifier, which would be 0 for the first item. Adding 1 twice warrants a 2 appended to the end, so on and so forth. And then I add 1 to it, then attempt to append it to the original name, in order to get a new name for it. Each time it spits out at me that: Parse error: syntax error, unexpected T_VARIABLE in aResults.php on line 20 Can anyone help me to figure out what I missed? Thanks! Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 7, 2007 Share Posted February 7, 2007 the line before it needs a ; to end it. Quote Link to comment Share on other sites More sharing options...
Kularian Posted February 7, 2007 Author Share Posted February 7, 2007 Urgh! I thought I looked for that too! Darn it...*sigh* Thanks for the help, I guess. I should've been able to figure that one out. Sorry to trouble you, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.