searls03 Posted June 2, 2011 Share Posted June 2, 2011 how can I basically do this? $event= $_GET['name123']; $site = '$event.php'; where $site = the get name123 with .php on it? Quote Link to comment https://forums.phpfreaks.com/topic/238234-php-variables-inside-variables/ Share on other sites More sharing options...
wildteen88 Posted June 2, 2011 Share Posted June 2, 2011 Variables are not parsed within single quotes. You can do either of the following $site = $event . '.php'; OR $site = "{$event}.php"; Quote Link to comment https://forums.phpfreaks.com/topic/238234-php-variables-inside-variables/#findComment-1224288 Share on other sites More sharing options...
searls03 Posted June 2, 2011 Author Share Posted June 2, 2011 do you see anything wrong in this code.....all of the sudden it stopped posting to database...... <?php include_once "secure/connect_to_mysql.php"; $uploaddir = 'images/'; $id= $_GET['id']; $event= $_GET['name123']; $site = "{$event}.php"; $file = $uploaddir . basename($_FILES['uploadfile']['name']); $size=$_FILES['uploadfile']['size']; if($size>999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999) { echo "error file size > 1 MB"; unlink($_FILES['uploadfile']['tmp_name']); exit; } if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { echo "success"; } else { echo "error ".$_FILES['uploadfile']['error']." --- ".$_FILES['uploadfile']['tmp_name']." %%% ".$file."($size)"; } $sql = "INSERT INTO pictures(image, id, event) VALUES('$file', '$id', '$event')"; $rs = mysql_query($sql) or die ("Problem with the query: $sql<br>" . mysql_error()); echo mysql_error(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/238234-php-variables-inside-variables/#findComment-1224301 Share on other sites More sharing options...
mikesta707 Posted June 2, 2011 Share Posted June 2, 2011 are you getting a mysql error? Can you post it and the query that is giving you problems Quote Link to comment https://forums.phpfreaks.com/topic/238234-php-variables-inside-variables/#findComment-1224304 Share on other sites More sharing options...
searls03 Posted June 2, 2011 Author Share Posted June 2, 2011 I was posting to wrong directory.......it working fine. Quote Link to comment https://forums.phpfreaks.com/topic/238234-php-variables-inside-variables/#findComment-1224306 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.