advancedfuture Posted June 21, 2008 Share Posted June 21, 2008 So I am creating a form to generate an invoice. and for some reason it the query that it generates enters a phantom charecture Here is the output I get from printing the query... i have bolded the error! INSERT INTO invoices (apartmentName, apartmentAddress, apartmentCity, apartmentState, apartmentZip, apartmentReferral, clientName, apartmentManager, apartmentPhone) VALUES ('Test Apartment', '7 Via Arribo', 'Rancho Santa Margarita', 'CA', '92688','', 'jason miller', 'cindy sheen', '949-555-1234') Notice it is the " inbetween '92688' and 'jason miller' I have NO IDEA where this is coming from. I have checked the database and there are no quote marks to be found! Here is the code for the invoice generation page. <?php include 'dbconnect.php'; $apartmentId = $_GET['apartmentId']; $clientId = $_GET['clientId']; $query = "SELECT * FROM apartments WHERE apartmentId = '$apartmentId'"; $results = mysql_query($query); while($row = mysql_fetch_array($results)) { $query2 = "SELECT * FROM inquiry WHERE clientId = '$clientId'"; $results2 = mysql_query($query2); while($row2 = mysql_fetch_array($results2)) { $apartmentName = $row['apartmentName']; $apartmentAddress = $row['apartmentAddress']; $apartmentCity = $row['apartmentCity']; $apartmentState = $row['apartmentState']; $apartmentZip = $row['apartmentZip']; $apartmentReferral = $row['apartmentReferral']; $apartmentManager = $row['apartmentManager']; $apartmentPhone = $row['apartmentPhone']; $clientName = $row2['firstName']." ".$row2['lastName']; $query3 = "INSERT INTO invoices (apartmentName, apartmentAddress, apartmentCity, apartmentState, apartmentZip, apartmentReferral, clientName, apartmentManager, apartmentPhone) VALUES ('$apartmentName', '$apartmentAddress', '$apartmentCity', '$apartmentState', '$apartmentZip','$apartmentReferral', '$clientName', '$apartmentManager', '$apartmentPhone')"; echo $query3; $results3 = mysql_query($query3) or die("error"); } } ?> Link to comment https://forums.phpfreaks.com/topic/111224-php-entering-phantom-charecture-in-mysql-query/ Share on other sites More sharing options...
DanielWhite Posted June 21, 2008 Share Posted June 21, 2008 Not that it should make a difference but see this: $apartmentState', '$apartmentZip','$apartmentReferral', Try changing: '$apartmentZip','$apartmentReferral', to: '$apartmentZip', '$apartmentReferral', See if it makes a difference. Link to comment https://forums.phpfreaks.com/topic/111224-php-entering-phantom-charecture-in-mysql-query/#findComment-570864 Share on other sites More sharing options...
advancedfuture Posted June 21, 2008 Author Share Posted June 21, 2008 nah that just spaced it out a bit... Link to comment https://forums.phpfreaks.com/topic/111224-php-entering-phantom-charecture-in-mysql-query/#findComment-570867 Share on other sites More sharing options...
DanielWhite Posted June 21, 2008 Share Posted June 21, 2008 Since it's your database I can't really help you, but I did this: <?php $apartmentName = 'Test Apartment'; $apartmentAddress = '7 Via Arribo'; $apartmentCity = 'Rancho Santa Margarita'; $apartmentState = 'CA'; $apartmentZip = '92688'; $apartmentReferral = 'jason miller'; $apartmentManager = 'cindy sheen'; $apartmentPhone = '949-555-1234'; $clientName = 'James'." ".'West'; $query3 = "INSERT INTO invoices (apartmentName, apartmentAddress, apartmentCity, apartmentState, apartmentZip, apartmentReferral, clientName, apartmentManager, apartmentPhone) VALUES ('$apartmentName', '$apartmentAddress', '$apartmentCity', '$apartmentState', '$apartmentZip', '$apartmentReferral', '$clientName', '$apartmentManager', '$apartmentPhone')"; echo $query3; ?> It was fine like that which suggests it's the coding above query3. Link to comment https://forums.phpfreaks.com/topic/111224-php-entering-phantom-charecture-in-mysql-query/#findComment-570871 Share on other sites More sharing options...
advancedfuture Posted June 21, 2008 Author Share Posted June 21, 2008 ok this is EXTREMELY bizzare I switches all the single quotes to double quotes and enclosed the query in single quotes. so it looks like $query3 = 'INSERT INTO invoices (apartmentName, apartmentAddress, apartmentCity, apartmentState, apartmentZip, apartmentReferral, clientName, apartmentManager, apartmentPhone) VALUES ("$apartmentName", "$apartmentAddress", "$apartmentCity", "$apartmentState", "$apartmentZip", "$apartmentReferral", "$clientName", "$apartmentManager", "$apartmentPhone")'; and now the phantom double quotes went away!! What the heck?? Link to comment https://forums.phpfreaks.com/topic/111224-php-entering-phantom-charecture-in-mysql-query/#findComment-570872 Share on other sites More sharing options...
advancedfuture Posted June 21, 2008 Author Share Posted June 21, 2008 woops i guess double quotes make the variables print out as varialbe names haha. back to square 1 Link to comment https://forums.phpfreaks.com/topic/111224-php-entering-phantom-charecture-in-mysql-query/#findComment-570874 Share on other sites More sharing options...
DanielWhite Posted June 21, 2008 Share Posted June 21, 2008 Tried it without any quotes? Link to comment https://forums.phpfreaks.com/topic/111224-php-entering-phantom-charecture-in-mysql-query/#findComment-570875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.