Clinton Posted November 14, 2012 Share Posted November 14, 2012 I've been racking my brain for about 2 hours... can't figure out why this isn't inserting into the database? I have verified that num_rows is coming back as 1 so it should be executing it accordingly. My webpage does echo "The End" so it's running through it correctly, it's just not running the INSERT INTO but not giving me a die error. It's the right table, the right everything... I just can't figure it out. if(mysql_num_rows($result)=='1'){ while($row = mysql_fetch_array($result)) { $uid = $row['id']; } $dob = $dobyear . "-" . $dobmonth . "-" . $dobday; $cred1expire = $year1 . "-" . $month1 . "-" . $day1; $cred2expire = $year2 . "-" . $month2 . "-" . $day2; $cred3expire = $year3 . "-" . $month3 . "-" . $day3; $cred4expire = $year4 . "-" . $month4 . "-" . $day4; $cred5expire = $year5 . "-" . $month5 . "-" . $day5; $homephone = preg_replace('/\D+/', '', $homephone); $cellphone = preg_replace('/\D+/', '', $cellphone); $dlnumber = preg_replace('/\D+/', '', $dlnumber); $dayphone = preg_replace('/\D+/', '', $dayphone); $evephone = preg_replace('/\D+/', '', $evephone); $oneyear = mktime(0,0,0,date("m"),date("d"),date("Y")+1); $annual = date("Y-m-d", $oneyear); mysql_query("INSERT INTO uinfo (uid,address,city,county,zip,homephone,cellphone,carrier,texts,dob,dlnumber,dlstate,languages,ename,relationship,dayphone,evephone,employer,position,waddress,wcity,wcounty,wzip,emergency,memployer,choice1,choice2,choice3,interest,interestedposition,travel,distance,length,transport,cred1,cred1num,cred1state,cred1expire,cred2,cred2num,cred2state,cred2expire,cred3,cred3num,cred3state,cred3expire,cred4,cred4num,cred4state,cred4expire,cred5,cred5num,cred5state,cred5expire,hear,contract,annual) VALUES ('$uid’,'$address’,'$city’,'$county’,'$zip’,'$homephone’,‘$cellphone’,‘$carrier’,‘$texts’,‘$dob’,‘$dlnumber’,‘$dlstate’,‘$languages’,‘$ename’,‘$relationship’,‘$dayphone’,‘$evephone’,‘$employer’,‘$position’,‘$waddress’,‘$wcity’,‘$wcounty’,‘$wzip’,‘$emergency’,‘$memployer’,‘$choice1’,‘$choice2’,‘$choice3’,‘$interest’,‘$interestedposition’,‘$travel’,‘$distance’,‘$length’,‘$transport’,‘$cred1’,‘$cred1num’,‘$cred1state’,‘$cred1expire’,‘$cred2’,‘$cred2num’,‘$cred2state’,‘$cred2expire’,‘$cred3’,‘$cred3num’,‘$cred3state’,‘$cred3expire’,‘$cred4’,‘$cred4num’,‘$cred4state’,‘$cred4expire’,‘$cred5’,‘$cred5num’,‘$cred5state’,‘$cred5expire’,‘$hear’,‘$contract’,‘$annual’)" or die (mysql_error())); echo $homephone; ?> The End. <? } else { ?> There has been an error. Please consult your webmaster for assistance. <br> <? }} ?> Quote Link to comment https://forums.phpfreaks.com/topic/270688-cant-figure-out-insert/ Share on other sites More sharing options...
computermax2328 Posted November 14, 2012 Share Posted November 14, 2012 Your mysql_error after the query has too many (). Take one off of the end. Tell me if that helps, I am going to look more into it. Quote Link to comment https://forums.phpfreaks.com/topic/270688-cant-figure-out-insert/#findComment-1392399 Share on other sites More sharing options...
Scott_S Posted November 14, 2012 Share Posted November 14, 2012 This part looks wrong ’)" or die (mysql_error())); The " should be inside and you might have too many ) You should also read this: http://www.phpfreaks.com/blog/or-die-must-die Quote Link to comment https://forums.phpfreaks.com/topic/270688-cant-figure-out-insert/#findComment-1392403 Share on other sites More sharing options...
computermax2328 Posted November 14, 2012 Share Posted November 14, 2012 I've been racking my brain for about 2 hours... can't figure out why this isn't inserting into the database? I have verified that num_rows is coming back as 1 so it should be executing it accordingly. My webpage does echo "The End" so it's running through it correctly, it's just not running the INSERT INTO but not giving me a die error. It's the right table, the right everything... I just can't figure it out. if(mysql_num_rows($result)=='1'){ while($row = mysql_fetch_array($result)) { $uid = $row['id']; } $dob = $dobyear . "-" . $dobmonth . "-" . $dobday; $cred1expire = $year1 . "-" . $month1 . "-" . $day1; $cred2expire = $year2 . "-" . $month2 . "-" . $day2; $cred3expire = $year3 . "-" . $month3 . "-" . $day3; $cred4expire = $year4 . "-" . $month4 . "-" . $day4; $cred5expire = $year5 . "-" . $month5 . "-" . $day5; $homephone = preg_replace('/\D+/', '', $homephone); $cellphone = preg_replace('/\D+/', '', $cellphone); $dlnumber = preg_replace('/\D+/', '', $dlnumber); $dayphone = preg_replace('/\D+/', '', $dayphone); $evephone = preg_replace('/\D+/', '', $evephone); $oneyear = mktime(0,0,0,date("m"),date("d"),date("Y")+1); $annual = date("Y-m-d", $oneyear); [code]mysql_query("INSERT INTO uinfo (uid,address,city,county,zip,homephone,cellphone,carrier,texts,dob,dlnumber,dlstate,languages,ename,relationship,dayphone,evephone,employer,position,waddress,wcity,wcounty,wzip,emergency,memployer,choice1,choice2,choice3,interest,interestedposition,travel,distance,length,transport,cred1,cred1num,cred1state,cred1expire,cred2,cred2num,cred2state,cred2expire,cred3,cred3num,cred3state,cred3expire,cred4,cred4num,cred4state,cred4expire,cred5,cred5num,cred5state,cred5expire,hear,contract,annual) VALUES ('$uid’,'$address’,'$city’,'$county’,'$zip’,'$homephone’,‘$cellphone’,‘$carrier’,‘$texts’,‘$dob’,‘$dlnumber’,‘$dlstate’,‘$languages’,‘$ename’,‘$relationship’,‘$dayphone’,‘$evephone’,‘$employer’,‘$position’,‘$waddress’,‘$wcity’,‘$wcounty’,‘$wzip’,‘$emergency’,‘$memployer’,‘$choice1’,‘$choice2’,‘$choice3’,‘$interest’,‘$interestedposition’,‘$travel’,‘$distance’,‘$length’,‘$transport’,‘$cred1’,‘$cred1num’,‘$cred1state’,‘$cred1expire’,‘$cred2’,‘$cred2num’,‘$cred2state’,‘$cred2expire’,‘$cred3’,‘$cred3num’,‘$cred3state’,‘$cred3expire’,‘$cred4’,‘$cred4num’,‘$cred4state’,‘$cred4expire’,‘$cred5’,‘$cred5num’,‘$cred5state’,‘$cred5expire’,‘$hear’,‘$contract’,‘$annual’)" or die (mysql_error())); echo $homephone; ?> The End. <? } else { ?> There has been an error. Please consult your webmaster for assistance. <br> <? }} ?>[/code] at the end of your query your () and "" are out of order. Your 'or die' is inside of your query and your "" are messed up. Try this: mysql_query("INSERT INTO uinfo (uid,address,city,county,zip,homephone,cellphone,carrier,texts,dob,dlnumber,dlstate,languages,ename,relationship,dayphone,evephone,employer,position,waddress,wcity,wcounty,wzip,emergency,memployer,choice1,choice2,choice3,interest,interestedposition,travel,distance,length,transport,cred1,cred1num,cred1state,cred1expire,cred2,cred2num,cred2state,cred2expire,cred3,cred3num,cred3state,cred3expire,cred4,cred4num,cred4state,cred4expire,cred5,cred5num,cred5state,cred5expire,hear,contract,annual) VALUES ('$uid’,'$address’,'$city’,'$county’,'$zip’,'$homephone’,‘$cellphone’,‘$carrier’,‘$texts’,‘$dob’,‘$dlnumber’,‘$dlstate’,‘$languages’,‘$ename’,‘$relationship’,‘$dayphone’,‘$evephone’,‘$employer’,‘$position’,‘$waddress’,‘$wcity’,‘$wcounty’,‘$wzip’,‘$emergency’,‘$memployer’,‘$choice1’,‘$choice2’,‘$choice3’,‘$interest’,‘$interestedposition’,‘$travel’,‘$distance’,‘$length’,‘$transport’,‘$cred1’,‘$cred1num’,‘$cred1state’,‘$cred1expire’,‘$cred2’,‘$cred2num’,‘$cred2state’,‘$cred2expire’,‘$cred3’,‘$cred3num’,‘$cred3state’,‘$cred3expire’,‘$cred4’,‘$cred4num’,‘$cred4state’,‘$cred4expire’,‘$cred5’,‘$cred5num’,‘$cred5state’,‘$cred5expire’,‘$hear’,‘$contract’,‘$annual’") or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/270688-cant-figure-out-insert/#findComment-1392405 Share on other sites More sharing options...
Clinton Posted November 14, 2012 Author Share Posted November 14, 2012 Thanks, folks. I did what you suggested and it still didn't work. Then, I finally figured it out and I feel like putting my head through a wall. My editor was acting screwy so I took the long statement and typed it in a document, so I could see it properly. Well, instead of ' it uses ’ . Oh how that little slant makes all the difference in the world and such a newb mistake. 8-\ Quote Link to comment https://forums.phpfreaks.com/topic/270688-cant-figure-out-insert/#findComment-1392407 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.