zarathu Posted November 22, 2006 Share Posted November 22, 2006 $someInt = rand(10000, 90000);$stuff = "whatever blah blah blah $someInt more blah blah blahs";echo($stuff);For some reason, the above doesn't work the way it should. It prints the string perfectly, BUT it won't show $someInt! Link to comment https://forums.phpfreaks.com/topic/28047-concatenation-of-a-random-integer/ Share on other sites More sharing options...
Philip Posted November 22, 2006 Share Posted November 22, 2006 Try:[code]$someInt = rand(10000, 90000);$stuff = "whatever blah blah blah " . $someInt . " more blah blah blahs";echo($stuff);[/code]although it works fine with me as well. Link to comment https://forums.phpfreaks.com/topic/28047-concatenation-of-a-random-integer/#findComment-128315 Share on other sites More sharing options...
hitman6003 Posted November 22, 2006 Share Posted November 22, 2006 Works fine for me.Are you getting any error messages? What result are you getting? Link to comment https://forums.phpfreaks.com/topic/28047-concatenation-of-a-random-integer/#findComment-128316 Share on other sites More sharing options...
zarathu Posted November 22, 2006 Author Share Posted November 22, 2006 [quote author=hitman6003 link=topic=115838.msg471785#msg471785 date=1164166407]Works fine for me.Are you getting any error messages? What result are you getting?[/quote]$newID = rand(10000,90000); //inserts shittles... watch me rule again. $bullshit = "INSERT INTO $mySQL_table ($mySQL_idField, $mySQL_strField) VALUES ($newId, $data)"; //$query = mysql_query($bullshit); echo($bullshit);^ That's the ACTUAL code that I'm trying to execute, but it just won't work. Also, Philip, your method doesn't work either. When I try to echo($newID) on its own, it prints it fine. It just won't concatenate. Link to comment https://forums.phpfreaks.com/topic/28047-concatenation-of-a-random-integer/#findComment-128320 Share on other sites More sharing options...
lilman Posted November 22, 2006 Share Posted November 22, 2006 maybe you need to use single quotes around your values: $bullshit = "INSERT INTO $mySQL_table ($mySQL_idField, $mySQL_strField) VALUES ('$newId', '$data')";if that doesn't do the trick put at the top of your code: error_reporting(E_ALL); and also: $query = mysql_query($bullshit) die("Error ". mysql_error() ." with query ". $bullshit); that should help in finding out what is causing the problem. Link to comment https://forums.phpfreaks.com/topic/28047-concatenation-of-a-random-integer/#findComment-128322 Share on other sites More sharing options...
Philip Posted November 22, 2006 Share Posted November 22, 2006 If that is your actual code... it's because you have 2 different variables:$newID$newId (notice the D's are different) Link to comment https://forums.phpfreaks.com/topic/28047-concatenation-of-a-random-integer/#findComment-128324 Share on other sites More sharing options...
zarathu Posted November 22, 2006 Author Share Posted November 22, 2006 [quote author=KingPhilip link=topic=115838.msg471793#msg471793 date=1164166930]If that is your actual code... it's because you have 2 different variables:$newID$newId (notice the D's are different)[/quote]Oh my God, I KNEW it was because of something BLATANTLY stupid!Thanks! >.<Ugh, I'm used to compiler errors because I'm a Java/C/C++ programmer. Gah! Link to comment https://forums.phpfreaks.com/topic/28047-concatenation-of-a-random-integer/#findComment-128326 Share on other sites More sharing options...
Philip Posted November 22, 2006 Share Posted November 22, 2006 Thats what happens when you type a tad too fast ;) Link to comment https://forums.phpfreaks.com/topic/28047-concatenation-of-a-random-integer/#findComment-128327 Share on other sites More sharing options...
Recommended Posts