Jump to content

l0gic

Members
  • Posts

    110
  • Joined

  • Last visited

Everything posted by l0gic

  1. For my sanity and others, can you wrap the code in BB Tags [code] at the start and [/code] at the end?
  2. Or... Change your SQL to use LIKE.. SELECT * FROM images WHERE image_name like '$newBasename%'; Which will look for anything that matches $newBasename followed by anything. So.. 'f21190299a795e9cf3439f7f62c223f79e023ab7%' would match 'f21190299a795e9cf3439f7f62c223f79e023ab7.jpg' but so would 'f21190299%'..
  3. Are you accepting only JPG files? You could just add ".jpg" on newBasename..?
  4. I don't believe so. I haven't used SHA1() much at all but from what I understand it returns an alphanumeric-only string. Is that not what you're doing already? Post the few lines of code that generate your filename, and the DB fieldnames you're using, etc.. I'll do a quick mock-up.
  5. // Not safe if filenames have a '.' in them $file = explode(".", "f21190299a795e9cf3439f7f62c223f79e023ab7.jpg"); $filename = $file[0]; // Returns: f21190299a795e9cf3439f7f62c223f79e023ab7 $fileext= $file[1]; // Returns: jpg Or you could use strlen and substr. There are many ways really.
  6. Are you expecting $table_name to be 'chicago' or 'Chicago'? $a == $b Equal TRUE if $a is equal to $b after type juggling. $a === $b Identical TRUE if $a is equal to $b, and they are of the same type. I would try this: <?php $var1 = "chicago"; // Make sure both strings/variables are lower-case. $var1 = strtolower($var1); $table_name = strtolower($table_name); // Echo them out and visually compare them. echo "Does " . $var1 . " == " . $table_name . " ?"; if($table_name == $var1) { $result = mysql_query("SELECT * FROM another_table WHERE username='$usernamee'"); while($row = mysql_fetch_array($result)) { $var2 = $row['var2']; $var2_new = $var2 * 2; mysql_query("UPDATE another_table SET var2 = '$var2_new' WHERE username = '$usernamee'"); } } ?> And visually compare the output.
  7. I may be wrong but shouldn't you be getting a parse error with: $sql = "SELECT * FROM posts WHERE postTopic =" . mysql_real_escape_string($_GET['id']) . "; ..due the the last double quote 'opening' but not being 'closed'? I'd imagine $sql = "SELECT * FROM posts WHERE postTopic =" . mysql_real_escape_string($_GET['id']); ..would suffice? Either way.. Do you actually need the 'AND' in the query, I can't see all your code but it seems redundant. Edit: Fixed typo.
  8. I was watching x-men earlier, just popped back to check this out but it sounds like you've got it all under control! Good luck with your project.. And don't forget to marked this as solved.
  9. I know the code you've tried haven't worked, but you may consider posting any/it/some so we can see what you have tried (that you have tried) and what hasn't worked. From there we can help you find out why it didn't work.
  10. Answer was in your last thread.. <?php ... $paintFile = fopen("weeklyDataBoles.txt","r"); $year = fgets($weeklyDataBoles); // Replace $weeklyDataBoles with the file you're actually opening $paintFile ... ?>
  11. Pretty much, you want to post the same thing multiple times, ignore answers and not read manuals.
  12. You'll want a multi-dimensional array! <?php $questions = array( array("Question One", "Question One Text"), // id would be like $questions[0][*] array("Question Two", "Question Two Text"), array("Question Three", "Question Three Text"), ); ?> So.. <?php echo $questions[0][0]; // would echo "Question One" echo $questions[0][1]; // would echo "Question One Text" echo $questions[1][0]; // would echo "Question Two" echo $questions[1][1]; // would echo "Question Two Text" ?>
  13. I'm quite lazy, so this question to me reads like: Should I either: a) Write it all out and display it as a static page. or b) Write some code so I can enter the questions and what-not into the database, write the questions into the database, then write more code to display the questions and build the form. I'd pick 'a' in a heartbeat.. But I'd probley also do something weird like put each question into it's own file and include them in the script so that I can quickly just scan for 'question_#.inc.php' in the directory and make any changes to it. Or quickly find it in the main page and comment it out / remove it from the list of questions. It really depends on how often you can see yourself altering that one thing. If you were having different questions every week/month then I'd DB it, and if you did DB it then over time you might have a huge list of maybe 300 questions. Then you could randomly pick 10 from 300 and build a form dynamically from that, so each time the user does it (I hate when I put an 'it' right after an 'it') it appears to have changed and would impress them to no end. Otherwise, write it once, as simple and easy as you can. Implement. Profit.
  14. Try.. SELECT col3 FROM my_table WHERE col2=(SELECT MAX(col2) FROM my_table WHERE col4='A') I'm pretty sure you just have '(' in the wrong place.
  15. Ahh, okay. You really do want cron then. Most web-hosts should be able to offer a cron service.
  16. Why not just call 'scheduler.php' after the user has submitted the 'task'? Then it only runs when it needs to.
  17. A healthy combination of both would work well.
  18. I got stuck into the habit of naming variables based on what they are, I blame an old tutor for that. I name things like this. <?php // Strings.. $strFname = "Bruce"; // Integers $intMultiplier = 3; // Arrays $arrItems = array("itemone", "itemtwo", "itemthree"); I've grown on that now where if I want to name a variable by something that to me is descriptive (usually one or two words) if it's two words I condense the first word to the capital form of it's first letter.. So first name to me is $strFname, which means $strLname is last name. It really is a personal preference thing, and as you develop/code more you'll almost automitcally develop your own naming style/convention.
  19. Did 'Computer Science' not teach you how to use Google? So far in this thread you've pretty much been pushing people to 'help' you by doing the work for you. And getting sour when they wont. Perhaps you should ask your teacher if they can suggest any good resources that may help you. What you're asking from us is very hard for us to provide to you seeing as you don't understand the concepts and basic principles of PHP/MYSQL/etc.. Us giving you adivce on how to program this is like a mechanic giving head gasket replacement advice to a dentist. Have a look at what you said in the quote above.. Then let me pretend to be someone who wants to learn pyrotechnics and explosives. Here we go: (Warning! May contain a multitude of sarcasm) I'm hoping you can identify the problem here. And sure, yes you can learn PHP while you go, but start off with something a bit less complex.. - Create a script, learn loops and conditionals. - Make a form that 'sends' data (variables) to another page. - Connect to a database, add/modify and delete records. Then start combining them. Then if you get stuck, come and ask us for help with code you already have and not with non-existent code you haven't bothered to even try to write.. Even if it's pseudocode. Follow through some tutorials, don't just copy/paste and think "Yay, it works!" understand what it is you're doing witht he code, look at each line and think to yourself "What does that do?" example: This is all fine and dandy when copy/pasted.. <?php $str = "cat,dog,apple,peach,train"; $strarray = explode(",",$str); foreach ($strarray as $value) { echo $value; } ?> But you should be able to look at each line like this.. <?php $str = "cat,dog,apple,peach,train"; // I'm going to build a comma seperated string of items.. $strarray = explode(",",$str); // ..then explode that sting into an array.. foreach ($strarray as $value) { // ..and then loop through that array.. echo $value; // ..and echo each value (or item) out to the page. } ?> And when you can do the you may realise you want each item on a new line.. <?php ... echo $value . "<br>"; // I need to add a line break after each item! ... ?> And that's all it takes.. That and time.. And experience.. Maybe more than the two weeks you had to start with.
  20. Well, that's relationships between tables.. I'm talking complete different databases. you think the concept is any different? I would imagine it would be slightly different, same idea though. As I understand it for referential integrity to hold in a relational database, any field in a table that is declared a foreign key can contain only values from a parent table's primary key or a candidate key. I may have missed it but I have never seen a way to establish PK/FK relationships between different databases, not natively anyway.
  21. Well, that's relationships between tables.. I'm talking complete different databases.
×
×
  • 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.