-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
Haven't tested it (obviously), but this could be slightly leaner if(isset($_POST['submit'])) { foreach ($_POST as $k => $v){ if($v == '1'){ $id[] = $k; } } $ctx = new comment; foreach ($id as $x){ $ctx->commentdelete($x); } header('Location:admin.php'); }
-
add new member details to mysql database
Muddy_Funster replied to ckerr27's topic in PHP Coding Help
You need commas, change to this: VALUES( '{$_POST['username']}','{$_POST['firstname']}','{$_POST['surname']}','{$_POST[dob]}','{$_POST['wins']}','{$_POST['loses']}','{$_POST['email']}','{$_POST['born']}','{$_POST['other']}' )"; Also, be casrefull the order of things, you were off in your original code, I have fixed it. When addressing array keys in a parsed string use { and } around them to help the parser know what your doing. You really shouldn't EVER send raw user data to your database from an end user form. -
swap these two lines about $results = sqlsrv_query($conn, $describeQuery); $resultsx = sqlsrv_query($conn, $editQuery); Your pulling the info before you update it
-
[Help]Comparing two multi-dimensional arrays
Muddy_Funster replied to lahonda_99's topic in PHP Coding Help
Then something like: SELECT phone, cell, eval, active, division, station, email_work, email_home FROM roster LEFT JOIN schedual ON (schedual.unique_id = roster.unique_id) WHERE ( DATE(NOW()) = CAST(CONCAT_WS('-',year,month,day) as date) ) Should get back the information that you want in a single query. -
Having a hell of a time with arrays - need some help please.
Muddy_Funster replied to Jax2's topic in PHP Coding Help
ok, try this little change: //Populate array with valid ID's $sql="SELECT ID FROM riddles"; $result=mysql_query($sql,$db) or die(mysql_error()); while($row = mysql_fetch_assoc($result,$db)) { array_push($id_array, $row['ID']); }; $rand_key = array_rand($id_array, 1); $rand_value= $id_array[$rand_key]; echo $rand_value; -
Pretty sure this will error out all over the place, but I would try something like: SELECT Col1, Col2, Col3 FROM table1 WHERE( Col1 = 'A' AND DATE(Col3) IN ( SELECT DATE(Col3) as date_range FROM table 1 AS dt_table1 WHERE ( TIME(td_table1.Col3) IN ( SELECT MAX(TIME(Col3)) as max_time FROM table1 as tt_table1 GROUP BY DATE(tt_table1.Col3) ) ) ) ) ) .....actualy, no I woudln't, I'd already have a date column in the table that I could use for this lookup.
-
when magic_quotes are turned on
-
{ and } open and close a "code block" respectivly. It informs the PHP processor that everything between then is to be run in the even for the if, while, else, foreach etc. By not using them PHP defaults to run only the next single line of code as the event code and then dropt out of the condition back to the main page code. rule of thumb : if your not sure about it, use them.
-
Yeah, the question marks are me asking a question. What's the actual problem problem? What does your query do just now? I'm only assuming from having a glance that's what's happening, I'm not going to spend time providing a solution to a problem that may not even be related to what you are experiencing.
-
and the problem is what? you only get back the days the actualy worked?
-
What errors? chalk up another reason not to use select *
-
It's probably making mutliple matches because of the excessive use of LIKE. have you tried this? $sql = <<<SQL SELECT fields, that, you, want, and, need FROM resource INNER JOIN resource_skill ON (resource.Resource_ID = resource_skill.Resource_ID) INNER JOIN skill ON (resource_skill.Skill_ID = skill.Skill_ID) WHERE ( (First_Name LIKE '%$name%' OR Last_Name LIKE '%$name%' OR Skill_Name LIKE '%$name%') ) GROUP BY Skill_Name SQL; //-run the query against the mysql query function $result=mysql_query($sql); //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $First_Name =$row['First_Name']; $Last_Name=$row['Last_Name']; $Resource_ID=$row['Resource_ID']; //-display the result of the array echo "<ul>\n"; echo "<li>" . "<a href=\"a.php?id=$Resource_ID\">" .$First_Name . " " . $Last_Name . "</a></li>\n"; echo "</ul>"; } }
-
Think about how you are going to identify if it is the admin user or not. Think about what information you have at your disposal that will let you do that. Think about getting that information into your script in a safe and usable way. Think about using a better login script as a learning tool.
-
Excelent! So I was just being completly stupid Note to self : assign the variable within the eval, don't assign the eval to the variable!
-
[Help]Comparing two multi-dimensional arrays
Muddy_Funster replied to lahonda_99's topic in PHP Coding Help
let me see your tables, the thing about running queries in loops is that I have only ever found 1 instance where it HAD to be done, all the rest just needed a single querie with joins -
Yeah, I thought I was doing that: $a = '*2'; $b = '10'; $d= $b.$a.";"; $e = 10*2; $c = eval("$d"); echo "<pre>"; var_dump($c); var_dump($d); var_dump($e); echo"</pre>"; Returns: NULL string(5) "10*2;" int(20) Like I said, I have to be missing something here because $e looks exactly like the var_dump of $d to my eyes
-
OK, I'm clearly missing something: $a = '*2'; $b = '10'; //$c = eval("$b ". $a); = Unexpected $end //$c = eval("$b ". $a.";"); = var_dump($c) returns null //$c = eval("$b $a;"); = var_dump($c) returns null //$c = eval($b $a.";"); = Unexpected T_VARIABLE $d= $b.$a ; //$c = eval("$d;"); var_dump($c) = Null / var_dump($d) = string(4) "10*2"
-
I was really looking for the results of "DESCRIBE table1" and "DESCRIBE table2" if you would be so kind.
-
when I tried the following 3 options : $a = '* 1.2'; $b = '10'; $c = eval("$a ".$b); //$c = eval("$a $b"); //$c = eval($a ." $b"); echo $c; I got Does it not like math operators or am I doing it wrong?
-
post up accurate table information please, your using select * so all we know is your table names, not your field names. We also need to know keys and relations. You're also running 1 query within the return loop of another - that's just naughty.
-
Curious...If I store values and operators in a DB table and want to use them to perform calculations, how would I go about doing that? eg. Table has an "operator" column with |* 1.5|/ 0.75|+ 1.2| and I want to do something like desired_value = set_value affected by operator and value from table column, so if set_value = 10 I would want desired_value = 10 * 1.5 desired_value = 10 / 0.75 desired_value = 10 + 1.2 Anything like that possible?
-
[Help]Comparing two multi-dimensional arrays
Muddy_Funster replied to lahonda_99's topic in PHP Coding Help
Have you thought about changing the actual query to only return the information that you want? -
I think it's likely this line, take the @ off and see what happes then $file = trim(@file_get_contents('http://hiscore.runescape.com/index_lite.ws?player='.$user));//Runescape high scores