Jump to content

pengu

Members
  • Posts

    154
  • Joined

  • Last visited

    Never

Everything posted by pengu

  1. Totally beat to this. Look up inner joins. It'd have to be something like this. SELECT COUNT( a.id ), COUNT( b.search_price ) FROM basket AS a INNER JOIN products AS b ON a.id = b.id WHERE a.ip_address = "'.$_SERVER["REMOTE_ADDR"].'" AND b.for_sale = "yes" On second thought and after some testing. I think this will work. SELECT COUNT( a.id ) AS ACount, (SELECT COUNT( b.search_price ) FROM products WHERE for_sale = "yes") AS BCount FROM basket WHERE a.ip_address = "'.$_SERVER["REMOTE_ADDR"].'"
  2. Got this solved on Microsoft Forums. But also noticed I did my query wrong. SELECT Rez_Desc.Rez_Number AS RezNum, (SELECT OD.Label FROM Offsite_Desc OD LEFT JOIN Rez_Desc AS RD ON OD.Offsite_ID = RD.Pickup_ID AND RD.Rez_ID=Rez_Desc.Rez_ID) AS Pickup, (SELECT AR.Label FROM Arrival_Desc AR LEFT JOIN Rez_Desc AS RD ON AR.Arriving_ID = RD.Arriving_ID AND RD.Rez_ID=Rez_Desc.Rez_ID) AS DropOff FROM Rez_Desc In the sub queries I forgot to put "WHERE". I did a join then just said "AND" lol my bad.
  3. *bump* I guess The way I want it too read is.
  4. Hello. I'll start with the table structures. Rez_Desc - Table Arrival_Desc - Table OffSite_Desc - Table Here is my query (simplified), where I am receiving the error. SELECT Rez_Desc.Rez_Number AS RezNum, (SELECT OD.Label FROM Offsite_Desc OD LEFT JOIN Rez_Desc AS RD ON OD.Offsite_ID = RD.Pickup_ID AND RD.Rez_ID=Rez_Desc.Rez_ID) AS Pickup, (SELECT AR.Label FROM Arrival_Desc AR LEFT JOIN Rez_Desc AS RD ON AR.Arriving_ID = RD.Arriving_ID AND RD.Rez_ID=Rez_Desc.Rez_ID) AS DropOff FROM Rez_Desc Msg 512, Level 16, State 1, Line 1 Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. And finally this is the error message I am receiving. To my knowledge and understanding it is being caused because the sub query is returning more than 1 result which it should not be doing. Seeing as how in my example table above I have 2 entries, both with relevant ID's etc. Need some help!
  5. As Pikachu said. Change mysql_select_db(mschgdb) or die "Unable to select database"); To mysql_select_db(mschgdb) or die ("Unable to select database");
  6. Assuming he did mean this a INNER JOIN or LEFT JOIN would be the SQL to use. http://www.w3schools.com/sql/sql_join_inner.asp - etc etc
  7. There are some great tutorials on this website. But if you want to get started and back into it again (I had the same problem) try this website : http://www.w3schools.com/php/default.asp I found it good to get back into PHP
  8. RSS feeds I thought. XML stuffs.
  9. *bump* again I know this is possible.
  10. Don't use iFrames, they're really bad. On that register.php page, click go back to main page and then click 'register' again. Watch it completely bugger up. Use a Header -- Content -- Footer system or something. Also would be a good idea to post up some code.
  11. Had no idea of that website. Will be using that in the future. SELECT count(column) AS ColumnCount FROM movies
  12. You should have a box with a red 'x' in it where the image is supposed to be. Check the properties of that and make sure it's pointing to the correct path. Really depends how your folders are setup, like if this script is in a folder called functions for example and your trying to get the 'image' folder which is back in the root directory that's not going to work. You'd have to go '../images/bla.jpg'
  13. Any number of things. Different PHP/MySQL versions. Different permission for MySQL databases etc.. etc..
  14. Do some basic trouble shooting, see if there is any data in the variables. With $_GET & $_POST I've always done them with ' & '. So for example $_POST['hello']. But I don't think this matters.. Try the following code to see if anything is being printed. $DBhost ="localhost"; //mysql-server $DBuser = "root"; //mysqluser $DBpass = "123"; $DBName = "learnphp"; $table = "information"; echo $_POST['id']. "<br />"; echo $_POST['name']. "<br />"; echo $_POST['email']. "<br />"; echo $_POST['opinion']. "<br />"; //mysql_connect($DBhost,$DBuser,$DBpass) or die("error"); //mysql_select_db("$DBName") or die("error"); //$sqlquery = "INSERT INTO $table VALUES ('$_POST[id]','$_POST[name]','$_POST[email]','$_POST[opinion]')"; //$results=mysql_query($sqlquery); //mysql_close(); //echo "<html><titile>PHP and mysql</title><body><p><center>you just enter this information into the database //<p><blockquote>"; //print "Name:$_POST[name]<p>E-mail:$_POST[email]<p>opinion:$_POST[opinion]</blockquote></center>";
  15. Could you post up more of your code? The form file, session.php etc..
  16. Hey Guys, How are custom Mime Types achieved? Had a quick search through the forums, and most of the posts relate to mail() questions. Did a google search and found a completely useless article that told me to edit a non-existent text box. Quick example, the file type I want is .WAgame, I got this far before I realised what I was doing didn't make sense. So I looked up mime types, knowing that this file would not exist. if ($_FILES["file"]["type"] != "file/WAgame") { naughty! } Help! Edit:
  17. I realised how poorly this question was posed. I do not have as strong a grasp on AJAX as I thought. Nevermind. I'll do it another way.
  18. Don't actually know if this is possible. Going to post snippets, tell me if more code is required. I have a page called profile.php It shows your profile, I have a link called edit. Upon clicking it, I want aJAX to refresh the DIV with some information obtained from 'functions.php'. Snippet of profile.php <div class=\"pLine\"> <b>Profile Options</b> <a href=\"javascript:editProfile(test)\">[+] Edit</a><br /> </div> <div id=\"myProfile\"> <br /> <b>Email:</b> " .$row['email']. "<br /> <b>Date Joined:</b> <i>" .$row['date_joined']. "</i><br /> <b>Clan:</b> z<br /><br /><br /> </div> functions.js function editProfile(str) { if (str=="") { document.getElementById("myProfile").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myProfile").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","functions.php?q="+str,true); xmlhttp.send(); } functions.php <?php $q = $_GET['q']; switch ($q) { case 'test': echo "<div class=\"important\">This worked!</div>"; break; } ?>
  19. afrojojo - Your way worked. But it's not how I wanted to handle my errors. Thank you Premiso & AlexWD.
  20. Hi guys. Quick question, couldn't find any examples on php.net. I want to do a check to see if a $variable has alphanumeric characters, if it does not, spit an error at them. <?php $team_name = 'hello01'; if (!preg_match('[a-zA-Z0-9]',$team_name)) { echo "Team Name must contain alphanumeric characters."; exit(); } ?> This still gives me the error message, can you not use '!' with preg_match?
  21. SQL query, using your date_added column.
  22. *BUMP* Ok I have a sort of new question. I have gathered a bit more information. Example table. How would I link all these together based on a where searching for the 'client_id'. As far as I got. Which nearly shows everything. select tr.trans_id, tr.client_id, tr.trans_desc,tr.trans_total, tr.ref_number, tr.cash_receipt_number from transactions inner join transactions as t on transactions.ref_number = t.ref_number inner join transactions as tr on t.cash_receipt_number = tr.cash_receipt_number where transactions.client_id = 3666 It's not picking up the orignal payment.. not sure if it can. I may have solved this myself. edit: unless i select "transactions.*"...really confused myself. It appears on the left..
×
×
  • 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.