Jump to content

j33baS

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

j33baS's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi im trying to make a little script to improve a registration page, its your standard affair with 2 password textfeilds which need to equal each other and a jpg with text in which the user must type out, looks sumthing like ... <?php if($_POST['submit']) { if($_POST['password'] == $_POST['password2']){ if($_POST['verifyimg'] != "1234"){ require("header.php"); echo "you did not type out the text in the image correctly"; } else { $sql = "IBIG SILLY QUERY"; blahblah } } else{ require("header.php"); echo "you mistyped your password"; } } else { require("header.php"); ?> forms and submit button .... I realise this is a very silly and ugly way to do it and it also doesnt completely work... If you type the text in the image, it performs the query without checking the password if they are left empty, because empty == empty. Is there a way i could improve this ? I was thinking a list of else if's ? but can i compare 2 conditions in one go ? for example ... else if(password1 == password2) && (image = imagetxt){ } Any help greatly appreciated, im far from the best programmer !
  2. awesome ! Thanks man
  3. Hi i've been searching around for a way to perform an addition to all the reults from a while loop but cant really crack it and was wondering if anyone could point me in the right direction ! If i have a table like this ... SCORES (playername, score) Player1 - 3 Player1 - 5 Player1 - 1 Player1 - 6 Player2 - 2 Player2 - 3 and a query like this ... <?php $sql = "SELECT * FROM scores where playername = $playername"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)){ echo "playername and score..."; } ?> will output fro "player1" ... Player1 - 3 Player1 - 5 Player1 - 1 Player1 - 6 what can i do to get all those scores added up ? so i can have ... total = 15 ive been messing around making the "score" variable = to a variable $x and trying to do $x++ or sumthing ? do i have to make some sort of function ? would appreciate any help, cheers !
  4. awesome cheers guys! ...but wheres the "topic solved" mod gone ?
  5. $sql "SELECT * FROM 2points WHERE id = $id"; $result = mysql_query($sql); $row = mysql_num_rows($result); if($row == 0){ echo "nothing scored"; } else{ while ($row = mysql_fetch_array($result)){ echo "scores names etc"; } } ok sorry, i did miss a bracket! codes running fine now, except im not getting the output i want ! "Jacks" 2point query still displays nothing and not the text "nothing scored" ! and Gills querys both display the info fine. Thanks for the help guys, any more suggestions ?
  6. hey, thanks for helping! I already tried that ... Im getting an error sayig that theres an "Unexpected T_ELSE" but thats the path i was wanting to go down! Any reasons as to why it might be producing that error ? its not a problem having a while loop nested within the if ? cheers
  7. Hi I've spent ages googling this but cant find anything which helps so naturally I came here ! so let me explain ... I have a player profile page for a basketball site which will display the types of points scored by a player. Lets say I have two tables, one holding info(player name, number scored and opposition) on 3pointers and one for 2pointers 3 pointers jack - 5 vs reds jack - 3 vs blues jack - 4 vs greens Gill - 6 vs reds Gill - 4 vs blues 2 pointers Gill - 9 vs reds Gill - 8 vs blues The default profile page will have to contain queries for both the 2pointers and 3pointers tables. But Because jack hasn't scored and 2 pointers, his profile page will display the 3pointers he has scored, but the 2pointers bit will just be blank, I'd like it to say sumthing like "no 2 pointers scored yet" So im basically my code says... $sql "SELECT * FROM 2points WHERE id = $id"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)){ echo "...output scores, names etc"; } and the same goes for the 3pointers table .... but what im trying to do is more along the lines of ... if (this query exists){ $sql "SELECT * FROM 2points WHERE id = $id"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)){ ...output scores, names etc } } else{ echo "nothing scored yet"; } can anyone help me here? the codes not the problem because im getting the ouputs i want, its just the error handling, so I want "nothing scored yet" if the query is going to be empty cheers!
  8. bump! duno if i made it clear enough, but to reiterate, this line echo "<td><a href='viewfixture.php?id=" . $row['id'] . "'>Report</a></td>"; is taking $row['id'] from the categories table and i need to to be pulling "id" from the fixtures table. Should i be renaming the id field in each table? or is there some way around it like selecting $row['fixtures.id'] im stumped and love any suggestions! cheers
  9. yea man, i was just gona say i figured it out ! cheers anyway, im always doin stuff like this thanks
  10. I have the following code ... <?php if($_POST['submit']) { $validdate = checkdate($_POST['month'], $_POST['day'], $_POST['year']); if($validdate == TRUE) { $concatdate = $_POST['year'] . "-" . sprintf("%02d", $_POST['day']) . "-" . sprintf("%02d", $_POST['month']); $datesql = "INSERT INTO test(date) VALUES($concatdate);"; mysql_query($datesql); header("Location: " . $config_basedir . "/success.php"); } else { echo "date error"; } } else { require("header2.php"); } ?> <h2>Add New date</h2> <!-- ******** Date selector ******** --> <form method="post"> <table> <tr> <td>Day</td> <td>Month</td> <td>Year</td> </tr> <tr> <td> <select name="day"> <?php for($i=1;$i<=31;$i++){ echo "<option>" . $i . "</option>"; } ?> </select> </td> <td> <select name="month"> <?php for($i=1;$i<=12;$i++){ echo "<option>" . $i . "</option>"; } ?> </select> </td> <td> <select name="year"> <?php for($i=2008;$i<=2020;$i++){ echo "<option>" . $i . "</option>"; } ?> </select> </td> <td><input type="submit" name="submit" value="Go"></td> </tr> </table> </form> <!-- ******** END Date selector ******** --> <!-- ******** VIEW DATE ******** --> <?php //NOW() $titlequery = "SELECT * FROM test ORDER BY date DESC"; $titleresult = mysql_query($titlequery); while($row = mysql_fetch_array($titleresult)){ echo "<p>"; echo date("D jS F Y",strtotime($row['date'])); echo "</p>"; } ?> but theres a problem when the selected date is inserted into the database (test, which only has fields date(type date and id which is auto incrementing and the PK) and all thats being inserted is 0000-00-00. $concatdate should be inserting it as mysql's favorite YYYY-MM-DD format with the code for leading zero's and the hyphens in there as well! Was wondering if anyone could see any glaring errors ?! thanks
  11. okay iv got 3 tables set up in mySQL ... (fixtures) id <--- primary key cat_id <--- foreign key league_id <--- foreign key versus winlose score date report (categories) id <--- primary key cat (leagues) id <--- primary key league and my php... <table border="1" align="center"> <?php $titlequery = "SELECT fixtures.*, categories.*, leagues.* FROM fixtures, categories, leagues WHERE fixtures.cat_id = categories.id AND fixtures.league_id = leagues.id ORDER BY date ASC"; $titleresult = mysql_query($titlequery); while($row = mysql_fetch_array($titleresult)){ echo "<tr>"; echo "<td width=\"70\">" . $row['cat'] . "</td>"; echo "<td>" . $row['league'] . "</td>"; echo "<td>" . $row['versus'] . "</td>"; echo "<td>" . $row['win/lose'] . "</td>"; echo "<td>" . $row['score'] . "</td>"; echo "<td>" . $row['date'] . "</td>"; echo "<td><a href='viewfixture.php?id=" . $row['id'] . "'>Report</a></td>"; echo "</tr>"; } ?> </table> as you can see I have the results displayed in a table, that's working fine, but where I set up the link to the individual report for each entry.... $row['id'] .... identifies the individual entry, but it is currently taking the "id" from the "categories" table and NOT from the fixtures table which would uniquely identify the entry I am after! is it something to do with the way i have joined the tables? cant think how to sort it out ! Any help is appreciated, thanks
  12. ahh thanks again revraz !
  13. its 5.2.5, why does that look like it should work to you ?
  14. yea it just echoes 2nothing submitted" ???
  15. hmmm still doesn't work!
×
×
  • 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.