
Alex
Staff Alumni-
Posts
2,467 -
Joined
-
Last visited
Everything posted by Alex
-
I tested my example, and it worked for the limited examples I fed into it. But I'm a Regex amateur.
-
Oh, that's because you're using mysql_fetch_object, and not like mysql_fetch_assoc, or mysql_fetch_array.. Still if $row->music isn't working then there's something wrong with your query.
-
You still have to have it like.. <TEXTAREA name="music", ROWS="5", COLS="45", wrap=virtual>' . $row['music'] . '</TEXTAREA>
-
im sorry to sound ignorant but im not sure what you mean mate Don't you want the stuff inside the text area to be taken from the database? If your query is right, and there's a row in the table called 'music' replace $music with $row['music'] inside of your textarea.
-
$music the a $_GET variable, I thought you wanted it to get it from your query? Change it from $music to $row['music']
-
Show us more code.
-
That's fine as long as $music has the value you want..
-
Find 'my name is', and extract the word after that string... Help
Alex replied to cs.punk's topic in PHP Coding Help
Would that be the exact string? More specifically: Would it contain anything after it? How about before? -
Are they for the same thing? If so just use $_REQUEST which is like a hybrid of the two.
-
$text = preg_replace('/<img(.*)>/' , "<img $1 />", $text);
-
Just loop through the directory and display all the files with a link. $path = 'some path here'; $dir = dir($path); while($file = $dir->read()) { echo $file . ' - <a href="' . $path . $file . '">' . $file . '</a>'; }
-
Efficiency, the second example is easier, so I'd go with that one.
-
$msg = str_replace("%fname%", $fname, $msg); $msg = str_replace("%lname%", $lname, $msg); $msg = str_replace("%pname%", $poker_name, $msg);
-
Use: mysql_query('UPDATE players SET leader="yes" WHERE username="' . $_POST['username'] . '"'); Also, remember if your database isn't setup like this.. then it won't work. That query is made assuming that there's a colunm called 'leader' and when set to 'yes' it signifies that he/she is a leader.
-
Retrieving data using php and writing result to html
Alex replied to skimsurf4's topic in PHP Coding Help
Are updates so infrequent to the database that every time they're made it won't be annoying to rerun the file that will be creating the html file? If not.. $fp = fopen("somefile.html","w"); if(!$fp) { echo 'File could not be opened.'; exit; } fwrite("Stuff that's being written to the file"); fclose($fp); That's a basic example on how to write to a file. -
[SOLVED] Vexing T_Variable is driving me nutz - help!
Alex replied to Chezshire's topic in PHP Coding Help
Whoops, I also just noticed: It should be: $msg = "FROM: $name \n \n"; $msg .= "ISSUE, COMMENT OR CONCERN: $other \n \n"; If you're including the variable in the string you should use double quotes. -
if(isset($_POST['change_leader'])) { $result = mysql_query("SELECT gang_id FROM players WHERE username=" . mysql_real_escape_string($_POST['username']) . "' LIMIT 1"); $row = mysql_fetch_assoc($result); if($row['gang_id'] == $_POST['gang_id']) // Make sure he's a member of that gang { mysql_query('UPDATE players SET leader="yes" WHERE username="{$_POST['username']}"'); } } You should add a hidden field to your form which has the value of the gang id. So that you can confirm that the person they're choosing is actually a member of that gang (in case someone trys to hack it) I'm not exactly sure how your tables are setup, so it might be a little different.
-
[SOLVED] Vexing T_Variable is driving me nutz - help!
Alex replied to Chezshire's topic in PHP Coding Help
Well first off: $msg = 'FROM: $name \n \n'; $msg = 'ISSUE, COMMENT OR CONCERN: $other \n \n'; You basically removed the FROM:, Change it to: $msg = 'FROM: $name \n \n'; $msg .= 'ISSUE, COMMENT OR CONCERN: $other \n \n'; -
Retrieving data using php and writing result to html
Alex replied to skimsurf4's topic in PHP Coding Help
Are you sure you want to write it to a file? If you write it to a file then it will only be up-to-date every time you run that file again. Instead you can just run the query and echo out the results every time the page is run. That way everything that displays is always up-to-date. If you still want to write it to a file, you can look into fopen() and fwrite() -
[SOLVED] Vexing T_Variable is driving me nutz - help!
Alex replied to Chezshire's topic in PHP Coding Help
Whoops, I misnamed a variable on my last example. Still there was no problems.. <?php $other = 'something'; $thread_PostID = 550; $name_char = 'Alex'; $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: $other \n \n"; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: $thread_PostID \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; echo $msg; ISSUE, COMMENT OR CONCERN: something THREAD/POST: 550 CHARACTER(S): Alex -
[SOLVED] Vexing T_Variable is driving me nutz - help!
Alex replied to Chezshire's topic in PHP Coding Help
That shouldn't cause a problem. I even tested it, it worked fine: $other = 'something'; $thread_postID = 550; $name_char = 'Alex'; $msg .= (empty($other)) ? "" : "ISSUE, COMMENT OR CONCERN: $other \n \n"; $msg .= (empty($thread_PostID)) ? "" : "THREAD/POST: $thread_PostID \n \n"; $msg .= (empty($name_char)) ? "" : "CHARACTER(S): $name_char \n \n"; Output: ISSUE, COMMENT OR CONCERN: something CHARACTER(S): Alex I even tested for a syntax error when they're all null, no errors then either. -
[SOLVED] Vexing T_Variable is driving me nutz - help!
Alex replied to Chezshire's topic in PHP Coding Help
That shouldn't be causing your errors. I didn't see anything that should. It's just that if you have a variable within single quotes, it won't output the variables value. It'll evaluate it like a string. $variable = 'Some value'; echo "This variable has the value of $variable"; //Some value echo 'This variable has the value of $variable'; //$variable -
$result = mysql_query("Select COUNT(gang_id) FROM `players` WHERE gang_id='" . $gang['id'] . "'"); $row = mysql_fetch_assoc($result); echo $row['COUNT(gang_id)'];
-
And there's also a missing ' $sql = mysql_query("SELECT * FROM Bands WHERE bandname LIKE '{$search}%'");