Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. [code]<select name="status" id="status"> <option value="none">Please Select One</option> <?php // get list of status's $selectstat = "SELECT * FROM oak_status;"; $querystat = mysql_query($selectstat); // run query and display them while ($rowstat = mysql_fetch_array($querystat)) { echo "<option value=\"{$rowstat[statNo]}\"" . tempvar($rowstat['statNo'], $row['statNo']) . ">{$rowstat[status]}</option>\n"; // display them all } ?> </select><br />[/code] function [code]<?php // Function Start: // Function Name: tempvar() // Function Parameters: 2 // Function Process: This function is used for form's when it come's to making // the form drop down menu's stick.  This will allow it to pre-populate drop down menus function tempvar($variable, $testvariable) { if ($variable == $testvariable) { echo 'selected="selected"'; } } // end function ?> [/code] This is the function I am trying to use to get the drop down menu to 'remember' what was selected from the database.  I used this on another project, so I created this function, for now, it's technically working in theory like it's suppose to, but for some wierd reason, it output's it in the wrong area, based on the code at the top, it's outputting the following.  I am seeing this inside the html source code. [quote]<label for="status">*Status:</label><br /> <select name="status" id="status"> <option value="none">Please Select One</option> selected="selected"<option value="7">Complete - Portfolio</option> <option value="6">temp status</option> <option value="3">NOW!</option> <option value="4">Available Spring 2007</option> </select><br />[/quote] You see how it's outputing the select area somewhere inf ront of the option, I looked at the programming multiple time's, it should be outputting it inside the <option> like it should be <option value="7" selected="selected">Status Name</option> On whichever one was actually selected. But for some reason this isn't working, and I can't get it to output right.
  2. [quote]roopurt18[/quote] Thanks for the advice, and everyone else that helped. I tried your idea, and it worked, I am getting more into "array's, building querys', and stuff lately, so that is why I am still new to this type. I always did everything I did repetitively, but I got a lot of new functions for the framework. Thanks again for the help.
  3. Still stuck on this, for one the I is returning 94 when I echo it, but when I echo count($name) it tell's me 93 but even if I do [code]<?php //  build query $names = array("name", "t_number", "flighttype", "aircrafttype", "aircraftnumber", "eventdate", "eventtime", "flightnumber", "flightnumberselect", "scheduleddepartureairport", "scheduledarrivalairport", "captain", "firstofficer", "flightattendant", "additionalcrewmembers", "weather", "flightplan", "pax", "lapchildren", "actiontaken_abortedtakeoff", "actiontaken_canceledflight", "actiontaken_declaredemergency", "actiontaken_delayedflight", "actiontaken_diversion", "actiontaken_goaround", "actiontaken_groundaircraftatoutstation", "actiontaken_inflightshutdown", "actiontaken_missedapproach", "actiontaken_returnaircrafttomaintenance", "actiontaken_returntogate", "actiontaken_turnback", "phaseofflight", "classification_aircraftdamage", "classification_aircraftonrunway", "classification_aircraftlogsmanualsorphase", "classification_airportclosure", "classification_alternatorfailure", "classification_atcdelay", "classification_avionicsfailure_communication", "classification_avionicsfailure_navigation", "classification_battery", "classification_birdstrike", "classification_brakefailure", "classification_collision", "classification_crewincapacitation", "classification_debrisonrunway", "classification_deviationofatcinstructions", "classification_disruptiveorsickpassenger", "classification_doorwarning", "classification_doorwarningwhichone", "classification_dooropening", "classification_dooropeningwhichone", "classification_electricalfailure", "classification_emergencyevacuation", "classification_enginefailure", "classification_enginefire", "classification_fireorsmokeincabin", "classification_flapfailure", "classification_flattire", "classification_flightcontrolfailure", "classification_fuelleak", "classification_fuelquantity", "classification_hardlanding", "classification_icing", "classification_flightinstrument", "classification_flightinstrumentwhich", "classification_engineinstrument", "classification_engineinstrumentwhich", "classification_landinggear_blowdown", "classification_landinggear_failtoextend", "classification_landinggear_failtoretract", "classification_landinggear_hydraulicleak", "classification_landinggear_hydraulicsystemfailure", "classification_landinggear_falseindication", "classification_lighteningstrike", "classification_magnetofailedorrough", "classification_nearmidaircollision", "classification_paxinjury", "classification_propstrike", "classification_roughengine", "classification_runwayincursion", "classification_starterfailureorwarning", "classification_tailstrike", "classification_turbulence", "classification_vacuumfailure", "classification_waketurbulence", "classification_weatherbelowminimums", "classification_weatherbelowhighminimums", "classification_weightandbalance", "classification_windshear", "classification_other", "classification_othertext", "description"); $values = mysql_real_escape_string($_POST['search1field']); $values = "'%{$values}%'"; $select = "SELECT * FROM eventreport WHERE "; for ($i=0;$i<=count($names);$i++) {   if ($i == 94) { $select .= $names[$i] . " LIKE " . $values;   } else {     $select .= $names[$i] . " LIKE " . $values . " OR ";   } } $select .= "LIMIT $rownumber, $limit;"; // end building query ?>[/code] then it echo's the following (I also am echoign select a little further down. [quote]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/ninksafe/public_html/mainadmin/vieweventssearch.php on line 53 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE '%aszf%' OR LIMIT 0, 20' at line 1 SELECT * FROM eventreport WHERE name LIKE '%aszf%' OR t_number LIKE '%aszf%' OR flighttype LIKE '%aszf%' OR aircrafttype LIKE '%aszf%' OR aircraftnumber LIKE '%aszf%' OR eventdate LIKE '%aszf%' OR eventtime LIKE '%aszf%' OR flightnumber LIKE '%aszf%' OR flightnumberselect LIKE '%aszf%' OR scheduleddepartureairport LIKE '%aszf%' OR scheduledarrivalairport LIKE '%aszf%' OR captain LIKE '%aszf%' OR firstofficer LIKE '%aszf%' OR flightattendant LIKE '%aszf%' OR additionalcrewmembers LIKE '%aszf%' OR weather LIKE '%aszf%' OR flightplan LIKE '%aszf%' OR pax LIKE '%aszf%' OR lapchildren LIKE '%aszf%' OR actiontaken_abortedtakeoff LIKE '%aszf%' OR actiontaken_canceledflight LIKE '%aszf%' OR actiontaken_declaredemergency LIKE '%aszf%' OR actiontaken_delayedflight LIKE '%aszf%' OR actiontaken_diversion LIKE '%aszf%' OR actiontaken_goaround LIKE '%aszf%' OR actiontaken_groundaircraftatoutstation LIKE '%aszf%' OR actiontaken_inflightshutdown LIKE '%aszf%' OR actiontaken_missedapproach LIKE '%aszf%' OR actiontaken_returnaircrafttomaintenance LIKE '%aszf%' OR actiontaken_returntogate LIKE '%aszf%' OR actiontaken_turnback LIKE '%aszf%' OR phaseofflight LIKE '%aszf%' OR classification_aircraftdamage LIKE '%aszf%' OR classification_aircraftonrunway LIKE '%aszf%' OR classification_aircraftlogsmanualsorphase LIKE '%aszf%' OR classification_airportclosure LIKE '%aszf%' OR classification_alternatorfailure LIKE '%aszf%' OR classification_atcdelay LIKE '%aszf%' OR classification_avionicsfailure_communication LIKE '%aszf%' OR classification_avionicsfailure_navigation LIKE '%aszf%' OR classification_battery LIKE '%aszf%' OR classification_birdstrike LIKE '%aszf%' OR classification_brakefailure LIKE '%aszf%' OR classification_collision LIKE '%aszf%' OR classification_crewincapacitation LIKE '%aszf%' OR classification_debrisonrunway LIKE '%aszf%' OR classification_deviationofatcinstructions LIKE '%aszf%' OR classification_disruptiveorsickpassenger LIKE '%aszf%' OR classification_doorwarning LIKE '%aszf%' OR classification_doorwarningwhichone LIKE '%aszf%' OR classification_dooropening LIKE '%aszf%' OR classification_dooropeningwhichone LIKE '%aszf%' OR classification_electricalfailure LIKE '%aszf%' OR classification_emergencyevacuation LIKE '%aszf%' OR classification_enginefailure LIKE '%aszf%' OR classification_enginefire LIKE '%aszf%' OR classification_fireorsmokeincabin LIKE '%aszf%' OR classification_flapfailure LIKE '%aszf%' OR classification_flattire LIKE '%aszf%' OR classification_flightcontrolfailure LIKE '%aszf%' OR classification_fuelleak LIKE '%aszf%' OR classification_fuelquantity LIKE '%aszf%' OR classification_hardlanding LIKE '%aszf%' OR classification_icing LIKE '%aszf%' OR classification_flightinstrument LIKE '%aszf%' OR classification_flightinstrumentwhich LIKE '%aszf%' OR classification_engineinstrument LIKE '%aszf%' OR classification_engineinstrumentwhich LIKE '%aszf%' OR classification_landinggear_blowdown LIKE '%aszf%' OR classification_landinggear_failtoextend LIKE '%aszf%' OR classification_landinggear_failtoretract LIKE '%aszf%' OR classification_landinggear_hydraulicleak LIKE '%aszf%' OR classification_landinggear_hydraulicsystemfailure LIKE '%aszf%' OR classification_landinggear_falseindication LIKE '%aszf%' OR classification_lighteningstrike LIKE '%aszf%' OR classification_magnetofailedorrough LIKE '%aszf%' OR classification_nearmidaircollision LIKE '%aszf%' OR classification_paxinjury LIKE '%aszf%' OR classification_propstrike LIKE '%aszf%' OR classification_roughengine LIKE '%aszf%' OR classification_runwayincursion LIKE '%aszf%' OR classification_starterfailureorwarning LIKE '%aszf%' OR classification_tailstrike LIKE '%aszf%' OR classification_turbulence LIKE '%aszf%' OR classification_vacuumfailure LIKE '%aszf%' OR classification_waketurbulence LIKE '%aszf%' OR classification_weatherbelowminimums LIKE '%aszf%' OR classification_weatherbelowhighminimums LIKE '%aszf%' OR classification_weightandbalance LIKE '%aszf%' OR classification_windshear LIKE '%aszf%' OR classification_other LIKE '%aszf%' OR classification_othertext LIKE '%aszf%' OR description LIKE '%aszf%' OR LIKE '%aszf%' OR LIMIT 0, 20; Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/ninksafe/public_html/mainadmin/vieweventssearch.php on line 59[/quote] I have to figure out a way to fix this, I have been working with it the past 2-3 hours with no luck Anybody?
  4. Still Stuck here, I have tried everything, substring isn't working, and I can't figure out what is making that appear at the end of the last one, thanks.
  5. Sorry, i should have thought about that. I got that query working, and took that same script and modified it to something heavier, [code]<?php //  build query $names = array("name", "t_number", "flighttype", "aircrafttype", "aircraftnumber", "eventdate", "eventtime", "flightnumber", "flightnumberselect", "scheduleddepartureairport", "scheduledarrivalairport", "captain", "firstofficer", "flightattendant", "additionalcrewmembers", "weather", "flightplan", "pax", "lapchildren", "actiontaken_abortedtakeoff", "actiontaken_canceledflight", "actiontaken_declaredemergency", "actiontaken_delayedflight", "actiontaken_diversion", "actiontaken_goaround", "actiontaken_groundaircraftatoutstation", "actiontaken_inflightshutdown", "actiontaken_missedapproach", "actiontaken_returnaircrafttomaintenance", "actiontaken_returntogate", "actiontaken_turnback", "phaseofflight", "classification_aircraftdamage", "classification_aircraftonrunway", "classification_aircraftlogsmanualsorphase", "classification_airportclosure", "classification_alternatorfailure", "classification_atcdelay", "classification_avionicsfailure_communication", "classification_avionicsfailure_navigation", "classification_battery", "classification_birdstrike", "classification_brakefailure", "classification_collision", "classification_crewincapacitation", "classification_debrisonrunway", "classification_deviationofatcinstructions", "classification_disruptiveorsickpassenger", "classification_doorwarning", "classification_doorwarningwhichone", "classification_dooropening", "classification_dooropeningwhichone", "classification_electricalfailure", "classification_emergencyevacuation", "classification_enginefailure", "classification_enginefire", "classification_fireorsmokeincabin", "classification_flapfailure", "classification_flattire", "classification_flightcontrolfailure", "classification_fuelleak", "classification_fuelquantity", "classification_hardlanding", "classification_icing", "classification_flightinstrument", "classification_flightinstrumentwhich", "classification_engineinstrument", "classification_engineinstrumentwhich", "classification_landinggear_blowdown", "classification_landinggear_failtoextend", "classification_landinggear_failtoretract", "classification_landinggear_hydraulicleak", "classification_landinggear_hydraulicsystemfailure", "classification_landinggear_falseindication", "classification_lighteningstrike", "classification_magnetofailedorrough", "classification_nearmidaircollision", "classification_paxinjury", "classification_propstrike", "classification_roughengine", "classification_runwayincursion", "classification_starterfailureorwarning", "classification_tailstrike", "classification_turbulence", "classification_vacuumfailure", "classification_waketurbulence", "classification_weatherbelowminimums", "classification_weatherbelowhighminimums", "classification_weightandbalance", "classification_windshear", "classification_other", "classification_othertext", "description"); $select = "SELECT * FROM eventreport WHERE "; for ($i=0;$i<=count($names);$i++) { $values = mysql_real_escape_string($_POST['search1field']); $values = "'%{$values}%'";   if ($i == count($names)) {     $select .= $names[$i] . " LIKE " . $values;   } else {     $select .= $names[$i] . " LIKE " . $values . " OR ";   } } $select .= "LIMIT $rownumber, $limit;"; // end building query ?>[/code] It's working except, it is having a syntax error at the end [quote]SELECT * FROM eventreport WHERE name LIKE '%ad%' OR t_number LIKE '%ad%' OR flighttype LIKE '%ad%' OR aircrafttype LIKE '%ad%' OR aircraftnumber LIKE '%ad%' OR eventdate LIKE '%ad%' OR eventtime LIKE '%ad%' OR flightnumber LIKE '%ad%' OR flightnumberselect LIKE '%ad%' OR scheduleddepartureairport LIKE '%ad%' OR scheduledarrivalairport LIKE '%ad%' OR captain LIKE '%ad%' OR firstofficer LIKE '%ad%' OR flightattendant LIKE '%ad%' OR additionalcrewmembers LIKE '%ad%' OR weather LIKE '%ad%' OR flightplan LIKE '%ad%' OR pax LIKE '%ad%' OR lapchildren LIKE '%ad%' OR actiontaken_abortedtakeoff LIKE '%ad%' OR actiontaken_canceledflight LIKE '%ad%' OR actiontaken_declaredemergency LIKE '%ad%' OR actiontaken_delayedflight LIKE '%ad%' OR actiontaken_diversion LIKE '%ad%' OR actiontaken_goaround LIKE '%ad%' OR actiontaken_groundaircraftatoutstation LIKE '%ad%' OR actiontaken_inflightshutdown LIKE '%ad%' OR actiontaken_missedapproach LIKE '%ad%' OR actiontaken_returnaircrafttomaintenance LIKE '%ad%' OR actiontaken_returntogate LIKE '%ad%' OR actiontaken_turnback LIKE '%ad%' OR phaseofflight LIKE '%ad%' OR classification_aircraftdamage LIKE '%ad%' OR classification_aircraftonrunway LIKE '%ad%' OR classification_aircraftlogsmanualsorphase LIKE '%ad%' OR classification_airportclosure LIKE '%ad%' OR classification_alternatorfailure LIKE '%ad%' OR classification_atcdelay LIKE '%ad%' OR classification_avionicsfailure_communication LIKE '%ad%' OR classification_avionicsfailure_navigation LIKE '%ad%' OR classification_battery LIKE '%ad%' OR classification_birdstrike LIKE '%ad%' OR classification_brakefailure LIKE '%ad%' OR classification_collision LIKE '%ad%' OR classification_crewincapacitation LIKE '%ad%' OR classification_debrisonrunway LIKE '%ad%' OR classification_deviationofatcinstructions LIKE '%ad%' OR classification_disruptiveorsickpassenger LIKE '%ad%' OR classification_doorwarning LIKE '%ad%' OR classification_doorwarningwhichone LIKE '%ad%' OR classification_dooropening LIKE '%ad%' OR classification_dooropeningwhichone LIKE '%ad%' OR classification_electricalfailure LIKE '%ad%' OR classification_emergencyevacuation LIKE '%ad%' OR classification_enginefailure LIKE '%ad%' OR classification_enginefire LIKE '%ad%' OR classification_fireorsmokeincabin LIKE '%ad%' OR classification_flapfailure LIKE '%ad%' OR classification_flattire LIKE '%ad%' OR classification_flightcontrolfailure LIKE '%ad%' OR classification_fuelleak LIKE '%ad%' OR classification_fuelquantity LIKE '%ad%' OR classification_hardlanding LIKE '%ad%' OR classification_icing LIKE '%ad%' OR classification_flightinstrument LIKE '%ad%' OR classification_flightinstrumentwhich LIKE '%ad%' OR classification_engineinstrument LIKE '%ad%' OR classification_engineinstrumentwhich LIKE '%ad%' OR classification_landinggear_blowdown LIKE '%ad%' OR classification_landinggear_failtoextend LIKE '%ad%' OR classification_landinggear_failtoretract LIKE '%ad%' OR classification_landinggear_hydraulicleak LIKE '%ad%' OR classification_landinggear_hydraulicsystemfailure LIKE '%ad%' OR classification_landinggear_falseindication LIKE '%ad%' OR classification_lighteningstrike LIKE '%ad%' OR classification_magnetofailedorrough LIKE '%ad%' OR classification_nearmidaircollision LIKE '%ad%' OR classification_paxinjury LIKE '%ad%' OR classification_propstrike LIKE '%ad%' OR classification_roughengine LIKE '%ad%' OR classification_runwayincursion LIKE '%ad%' OR classification_starterfailureorwarning LIKE '%ad%' OR classification_tailstrike LIKE '%ad%' OR classification_turbulence LIKE '%ad%' OR classification_vacuumfailure LIKE '%ad%' OR classification_waketurbulence LIKE '%ad%' OR classification_weatherbelowminimums LIKE '%ad%' OR classification_weatherbelowhighminimums LIKE '%ad%' OR classification_weightandbalance LIKE '%ad%' OR classification_windshear LIKE '%ad%' OR classification_other LIKE '%ad%' OR classification_othertext LIKE '%ad%' OR description LIKE '%ad%' OR LIKE '%ad%'LIMIT 0, 20;[/quote] You see at the end OR LIKE I was trying to search my name "west" and it worked, because I had substr($select, 0, -16); I thought that would work, but instead when I search for a 2 letter word, it came upw ith this, so that won't work, it's dependent on the size of the text. So now what?
  6. [quote]UPDATE tbl SET name='sadd',t_number='david',flighttype='Part 135',aircrafttype='C402',aircraftnumber='N106CA',eventdate='12/05/1983',eventtime='0900',flightnumber='west',flightnumberselect='',scheduleddepartureairport='asd',scheduledarrivalairport='asd',captain='asd',firstofficer='asd',flightattendant='asd',additionalcrewmembers='asd',weather='asd',flightplan='VFR',pax='asd',lapchildren='asd',actiontaken_abortedtakeoff='Aborted Takeoff',actiontaken_canceledflight='',actiontaken_declaredemergency='',actiontaken_delayedflight='',actiontaken_diversion='',actiontaken_goaround='',actiontaken_groundaircraftatoutstation='',actiontaken_inflightshutdown='Inflight Shutdown',actiontaken_missedapproach='',actiontaken_returnaircrafttomaintenance='',actiontaken_returntogate='',actiontaken_turnback='',phaseofflight='Deplaning',classification_aircraftdamage='Aircraft Damage',classification_aircraftonrunway='',classification_aircraftlogsmanualsorphase='',classification_airportclosure='',classification_alternatorfailure='Alternator Failure',classification_atcdelay='',classification_avionicsfailure_communication='',classification_avionicsfailure_navigation='',classification_battery='',classification_birdstrike='',classification_brakefailure='',classification_collision='',classification_crewincapacitation='',classification_debrisonrunway='',classification_deviationofatcinstructions='',classification_disruptiveorsickpassenger='',classification_doorwarning='Door Warning',classification_doorwarningwhichone='wearsa',classification_dooropening='',classification_dooropeningwhichone='',classification_electricalfailure='',classification_emergencyevacuation='',classification_enginefailure='',classification_enginefire='',classification_fireorsmokeincabin='',classification_flapfailure='',classification_flattire='',classification_flightcontrolfailure='',classification_fuelleak='',classification_fuelquantity='',classification_hardlanding='',classification_icing='',classification_flightinstrument='',classification_flightinstrumentwhich='',classification_engineinstrument='Engine Instrument',classification_engineinstrumentwhich='sdfasdf',classification_landinggear_blowdown='',classification_landinggear_failtoextend='',classification_landinggear_failtoretract='',classification_landinggear_hydraulicleak='',classification_landinggear_hydraulicsystemfailure='',classification_landinggear_falseindication='',classification_lighteningstrike='',classification_magnetofailedorrough='',classification_nearmidaircollision='',classification_paxinjury='',classification_propstrike='',classification_roughengine='',classification_runwayincursion='',classification_starterfailureorwarning='',classification_tailstrike='',classification_turbulence='',classification_vacuumfailure='',classification_waketurbulence='',classification_weatherbelowminimums='',classification_weatherbelowhighminimums='',classification_weightandbalance='',classification_windshear='Wind Shear',classification_other='Other',classification_othertext='west',description='hello',='' WHERE id = '';[/quote] Ok this is what happened when I echod' the statement, there are a few problems if you could help, at the end it's still ,=" WHERE id so it's a little off. Also the id isn't passing, but I can check on that in a minute, that is probably me, any advice?>
  7. They are coming from a database and form. This is the edit portion, I pull the info from the database, register a bunch of sessions, so they are coming from sessions. THe name's in the database are slightly different though because of mysql naming rules, I can't have - so instead they have to be - for the database, and the database is also named differently, so the name/value's are different. I am trying out what you suggested right now.
  8. On an update query you need to do UPDATE tablename SET whatever = 'whatever' I have a huge query, that has 2 giant array's of equal values. THe 2 arrays are called $name $value I need to create a query that is going to do $update = "UPDATE eventreport SET $name = '$value' WHERE id = '$id';"; ok here is the thing, This is a simple query, but by hand I would have to go in and do $update = "UPDATE eventreport SET name = '$name', t_number = '$t-number' and so forth, it would be a lot is there a way to make it automatically put in the name = 'value', name2 = 'value2', name3 = 'value3 I was wanting to just put all of those in there dynamically to make the process faster? I was thinking about a foreach statement, pretty easy, but in relation to 2 array's? plus having to do them both I was thinking of this, but I dont know the affects $update = "UPDATE eventreport SET " . foreach ($name as $tempname) { echo $tempname; } . foreach ($value as $tempvalue) { echo $tempvalue; } . "WHERE id = '$id';"; then that would build the query, I would have to modify it some to work, and put in the comma's but does anyone have any ideas? actually even then it would throw out all the names, then all the values, instead of doing them together.
  9. pass that by me one more time
  10. place a marker variable or something like hte word body then do a string_replace or whatever on it, that is what I had to do to create dynamic php on a file, I had to get the file, copy it, and edit it, ehre is the code if that helps. [code]<?php session_start(); function read_file($file) {   if(!function_exists("file_get_contents"))return file_get_contents($file);   $ifile = fopen($file,"r");   $contents = false;   if($ifile) while (!feof($ifile)) $contents .= fgets($ifile);   fclose($ifile);   return $contents; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php include './includes/meta.inc.php'; ?> </head> <body> <?php include './includes/header.inc.php'; ?> <!-- Begin Content --> <div id="topimage"><img src="images/topimage.gif" alt="Face Image" /></div> <div id="rightcontent"> <?php if ($_SESSION['controller'] == true) { mysql_connect("localhost", other); mysql_select_db("hasbadse_hbservice"); // create user account. $errorhandler = ""; $insert = "INSERT INTO userinfo SET username = '$_SESSION[username]', password = '$_SESSION[password]', email = '$_SESSION[email]', subdomainname = '$_SESSION[subdomain]';"; mysql_query($insert); $select = "SELECT * FROM userinfo WHERE username = '$_SESSION[username]';"; $query = mysql_query($select); if ($row = mysql_fetch_array($query)) { // retrieve userid with user account. $id = $row['id']; } // end getting userid. $header = $_SESSION['header']; $text = $_SESSION['text']; $insertcms = "INSERT INTO usercms (text, userid) VALUES ('$text', '$id');"; if (!mysql_query($insertcms)) { $errorhandler .= "There was a problem inserting the Content Management Information.<br />"; $errorhandler .= "Please contact support about this problem.<br />"; } // VERY IMPORTANT, everything below is used for directory creation. $var = preg_replace('/[^\x09\x0A\x0D\x20-\x7F]/e', '"&#".ord($0).";"', $_SESSION['subdomain']); $dir = "userpages/$var"; mkdir("$dir", 0700); if (!mkdir) { $errorhandler .= "unable to create the directory. Please contact support or try again.<br />"; } $buffer = read_file($_SESSION['template']); $buffer = str_replace("hold", $id, $buffer); // here I can do all my changes to the buffer variable(which contains the file information) $outfile = fopen("userpages/{$var}/index.php", "w"); // open writeable fwrite($outfile, $buffer); fclose ($outfile); chmod("userpages/{$var}", 0755); chmod("userpages/{$var}/index.php", 0755); // VERY IMPORTANT, everything above here is used for directory creation. $insertdn = "INSERT INTO subdomain (path, subdomainname, userid) VALUES ('$dir', '$_SESSION[subdomain]', '$id');"; if (!mysql_query($insertdn)) { $errorhandler .= "There was a problem, please contact support immediately.<br />"; } // start check for error handler if ($errorhandler != "") { echo "<span style=\"color:red;\">"; echo $errorhandler; echo "</span>"; } if ($errorhandler == "") { ?> <h4>Thank You</h4> <p>Thank you for your purchase, you can go over to the administration page, and login there.</p> <a href="/useradmin/useradmin.php" title="User Admin">User Admin</a> <?php } }else { echo "You have to go through the entire signup process, before coming to this page, in order <br />"; echo "for your account to be able to be created.<br />"; } ?> <?php include './includes/footer.inc.php'; ?> </div> </body> </html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Thank You</title> </head> <body> </body> </html> [/code] You see what I mean, now however, here are my template pages, that I used, it shows you what I did in those pages, that allowed me to do my search and replace with regular expressions The template is chosen based on what they picked, for instance if they pick template1.php it takes it copies the information int eh file (the actual .php page itself), and saves it in another file, with the dynamic hcanges done to it.  Works pretty smoother Template1.php [code]<?php session_start(); mysql_connect("localhost", other); mysql_select_db("hasbadse_hbservice"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="/templates/template1/css/globaltemplate1.css" /> <title>Hasbadservice</title> </head> <body> <div id="wrapper"> <!-- Entire Header Area --> <div id="header"> <div id="leftheader"> <?php $selectuser = "SELECT * FROM userinfo WHERE id = 'hold';"; $queryuser = mysql_query($selectuser); if ($row = mysql_fetch_array($queryuser)) { ?> <pre> <?php echo $row['subdomainname'] . ".\n"; ?> HasBadService. Com </pre> <?php } ?> </div> <img src="/templates/template1/images/star.gif" id="star" alt="Star Symbol" /> </div> <!-- End Header Area --> <div id="leftcolumn"> </div> <div id="rightcolumn"> <!-- Not part of original template.  This was added in dynamically --> <div class="content"> <?php $select = "SELECT * FROM usercms WHERE userid = 'hold';"; $query = mysql_query($select); while ($row = mysql_fetch_array($query)) { echo "<h4>" . stripslashes($row['header']) . "</h4>"; echo "<p>" . stripslashes($row['text']) . "</p>"; } ?> </div> <!-- End section that was done dynamically --> </div> </div> <hr /> </body> </html>[/code] template2.php [code]<?php session_start(); mysql_connect("localhost", "hasbadse_joyel", "joyel"); mysql_select_db("hasbadse_hbservice"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="/templates/template2/css/globaltemplate2.css" /> <title>Hasbadservice</title> </head> <body> <div id="header"> <?php $selectuser = "SELECT * FROM userinfo WHERE id = 'hold';"; $queryuser = mysql_query($selectuser); if ($row = mysql_fetch_array($queryuser)) { echo strtoupper($row['subdomainname']) . ".HASBADSERVICE.COM"; } ?> <div id="bar">&nbsp;</div> </div> <div id="wrapper"> <div id="leftbox"> <div id="upper"></div> <div id="lower"></div> </div> <div id="rightbox"> <!-- This section is not part of the original content, it's all dynamic --> <div class="content"> <?php $select = "SELECT * FROM usercms WHERE userid = 'hold';"; $query = mysql_query($select); while ($row = mysql_fetch_array($query)) { echo "<h4>" . stripslashes($row['header']) . "</h4>"; echo "<p>" . stripslashes($row['text']) . "</p>"; } ?> </div> <!-- End dynamic addition --> </div> </div> <div id="footer"></div> </body> </html>[/code] As you can see, it is a bad way for some things,f or instance, if the database information chagnes all the old templates are lost, the people who created accounts, that's what my new "config" file is for instead.  BUt it gives you the idea of what you wanted to do.
  11. what are you talking about? I couldn't understand the post.
  12. Ah perfect, thanks, I will post it back here so I won't forget monday when I start working agian, adn I can modify it then.  It won't work like this, but I can keep the idea in my head on monday, the post will always be here. Quote - to help me remember Use the code $substr($array, 0, -2); to strip the last 2 letters off of an array string.
  13. His should work with everything, if not, then just expand it a little. If you are having problems. Integrate what he showed you into your code, test it out, see where it work's, adn where it doesn't see what you can do, then bring it back here, post the entire code again, and tell us what it does, what it doesn't do, and what you need help with. Then you can go from there.
  14. If it's deleting everything then it's not reading your if statement correctly, it must be an empty variable or something, because if a delete query is issued on something, without a specifier it removes everything.
  15. You can also run a foreach,a nd just use pregmatch on them one at a time, with a foreach statement
  16. See, there you go, the script that guy gave you shoudl work totally. Regular expressions are powerful
  17. $docroot = $_SERVER['DOCUMENT_ROOT']; When you are ready to actual send the file put $docroot . "path" which in your case looks like $docroot . "pendingimages"
  18. Ah ok, I see what you mean regular expressions, you would have to use regular expressions to hunt down the link, and change it to an anchor, have it place a <a href=" before it, and then have hte link, then have it put a " title="if you want one">name here</a> you have to have it insert all of that where you want using string replace, and search and find fucntions, comparing strings, you are tlaking about working with regular expressions, above what I know about regular expressions, but that is going tobe where you want to look.
  19. This doesn't really make sense to me, it's heavily malformed I prefer id has weight:bold; <span id="news">Important News</span> <?php $number = "1"; $category = "4"; $template = "important"; include("nfnews/show_news.php"); ?> <B>Normal News</B> <?php $val = $_GET['nfn']; $val .= ".php"; $dirty = array(".."); $clean = array(""); $val = str_replace($dirty, $clean, $val); if (isset($_GET['nfn'])) { if (file_exists($val)) { include "$val"; }else { include "index.php"; } }else { $number = "3"; $show_calendar = true; include "nfnews/show_news.php"; } ?> Now that it's where I can read it, let's see about what we can do. $number = "3"; it should be $number = 3; All of those numbers shouldn't be turned to a string, that could be part of it. Trying cleaning it up as shown (so I can read it to help), and try changin those, when you put "3" you are telling php that 3 is a string, it may need to be a number for what you are trying to do. Try that first.
  20. again, like he said echo out ech o "<a href="url" title="title">Name</a> You could do this dynamically, just send the titel the array you saved the mysql fetch array in.
  21. [code]<?php foreach ($actiontaken as $val1) { if ($val1 != "") { $val1 = $val1 . ", "; } } ?>[/code] \Ok I formed both set's of arrays, classification and actiontaken. Not that big of a deal, easy to update later, and finished. Now, I went ahead and did a few feature based things, and ran back into this, so I looked at your post, and got your advice, but I had a few questions. Here is the first part, which was simple. I have used substr() before, but It was only for a few things and that was when working with url's THis time around, I needed to (as you said) strip off the last 2 characters, the , and the space after it I was wondering how to do that, or a pointer, I was thinknig substr() as you said, but it wouldnt' work would it, It only accepts 3 characters and 2 are numbered characters. I wouldn't be able to tell it where, but I was thinking regular expressions instead (unless there is something about substr() i don't know. BUt regular expressions would be aggravating for this, so then I thought about split, would there be any problems with using split, but then again it would try to find every occurence, I don't know how to go about that part.
  22. If you use the other technique if (whatever) { } then you can always associate the { with the control structure very easily, there are 3 different named styles to the placement of the bracket, this is the one that was recommended to be the easiest to debug, then all you have to do is match the number of closing one's with the number that you can obviously count next to the control structures. also by what I have heard creating a shopping cart system to a flat file isn't safe, but that's just what I heard, I could be wrong.
  23. I have seen a lot of people do $variable = new array(array, variables, here); and that is what I see people telling me, and see in tutorials WHen I do that, I ALWAYS get error messages, so I had to always do $variable = array(array, variables, here); why is that
  24. Sorry I was in a hurry, it's the same thing whether i had them in another table, or in the same one. However I tried it with actiontaken, I just put them all in an array, and did this [code]<?php $actiontaken = array($row['actiontaken_abortedtakeoff'], $row['actiontaken_canceledflight'], $row['actiontaken_declaredemergency'], $row['actiontaken_delayedflight'], $row['actiontaken_diversion'], $row['actiontaken_goaround'], $row['actiontaken_groundaircraftatoutstation'], $row['actiontaken_inflightshutdown'], $row['actiontaken_missedapproach'], $row['actiontaken_returnaircrafttomaintenance'], $row['actiontaken_returntogate'], $row['actiontaken_turnback']); foreach ($actiontaken as $val1) { if ($val1 != "") { echo ", " .$val1; } } ?>[/code] It work's except for one problem. THe comma is either at the beginning, or at the end of the last, or first. If there is only one then there is still , word it's a little unprofessional, so I was playing with it, to figure out how and only append the comma "after" the first one, but only if there are other one's after it, and to stop a comma at the last one, so there isn't a beginning or trailing comma. Other than that one thing it works great, and I can do the same idea when I need to start saving them all within a session, it'll be a little more tricky but it should work out well, when I need to feed it back to the creation form for editing.
×
×
  • 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.