Jump to content

[SOLVED] concatenation operator issues


Kularian

Recommended Posts

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!

Link to comment
Share on other sites

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.