Jump to content

rockonxox

New Members
  • Posts

    8
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

rockonxox's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am having issues with apostrophe's when using a form to insert/update/edit information in my database. My original code works unless an apostrophe is used: <?php $con=mysqli_connect("CONNECTIONINFORMATION"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result=mysql_query("INSERT INTO $table wf_FirstName1,wf_LastName3) VALUES ('".mysql_real_escape_string($wf_FirstName1)."', '".mysql_real_escape_string($wf_LastName3)."')"; $sql="INSERT INTO nominatedsires (ecuid,sirename,yob,color,breed,owner,approved) VALUES ('$_POST[ecuid]','$_POST[sirename]','$_POST[yob]','$_POST[color]','$_POST[breed]','$_POST[owner]','no')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "Thank you for your nomination.<br>Please send $1000 nomination fee to Andie so your nomination can be approved.<p><a href='nominateasire.php'>Nominate another stallion</a>"; mysqli_close($con); ?> I have been scouring forums, tutorials, etc but I can not get mysqli_real_escape_string to work so I'm obviously using it wrong. This code below doesn't give me an error (like many other attempts have). It gives me the thank you message but the information that goes into the database is blank. <?php $con=mysqli_connect("CONNECTIONINFORMATION"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO nominatedsires (ecuid,sirename,yob,color,breed,owner,approved) VALUES ('".mysqli_real_escape_string($_POST[ecuid])."', '".mysqli_real_escape_string($_POST[sirename])."', '".mysqli_real_escape_string($_POST[yob])."', '".mysqli_real_escape_string($_POST[color])."', '".mysqli_real_escape_string($_POST[breed])."', '".mysqli_real_escape_string($_POST[owner])."', 'no')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "Thank you for your nomination."; mysqli_close($con); ?> What is the proper way for me to use real escape string to deal with apostrophe's in this form?
  2. I have a database of all the horses I own. All I want to do is list them on my site and have their name linked to their ID# in the database. When their name is clicked, I want information to be shown based on that ID#. How should I go about this? I am thinking I need a second page with how I want the horse information to be shown. Am I correct in thinking this and if so how should I set it up? The horses id is 'hid' in the database.
  3. **Bump** Can anyone help... or do I need to explain myself better? Hopefully it's understandable!!!
  4. Not sure if that will work. Hfname is just a column fieldname... I want to be able to get results like this: Member has 0 presents Kelly Alia Candymara Member has 1-3 presents Tigerlily Dana KirstinVP Members has 5-10 presents JillianVP Member has 10+ presents None So I'd need to count rows based on how many times a value occurs in the hfname column...
  5. Okay, another ? but since it pertains to a different database I'm using a new topic. Click on a link, and you will see that the results show between the previous code... which is expected because I don't know how to do this any other way. Also, when I click on the ID, no info is shown... at least not on the 0_horselist.php link. Don't mind the layout, I'm not worried about looks till I get the queries & all working. Here is the site in it's current state: [a href=\"http://visionseq.com/hfhorses/0_horselist.php\" target=\"_blank\"]http://visionseq.com/hfhorses/0_horselist.php[/a] What I want it to look like: [a href=\"http://visionseq.com/hfhorses/0_listhorseinfo.php\" target=\"_blank\"]http://visionseq.com/hfhorses/0_listhorseinfo.php[/a] Is this possible? I'm also looking for information on how to let users search my database, so any resources I can look at would rock. I've got the search form, now I just need to figure out how to make it do something! --------- Here is my code for 0_horselist.php: <?php include 'horsesearch_connect.php'; include 'opendb.php'; if(isset($showdetails)){ $id=(int)$_GET['showdetails']; $result=mysql_query("SELECT * FROM hlist WHERE ID=$id"); $row=mysql_fetch_array($result); echo "<center><h3>{$row['title']} {$row['name']}</h3>" . "<hr color=black width=25%>" . "<font color=grey>#{$row['id']}</font> {$row['year']} {$row['color']} {$row['breed']} {$row['sex']}<br>" . "{$row['sire']} x {$row['dam']}" . "<hr color=black width=25%><P>" . "A Picture would go here<P>" . "<table width=80% border=1 bordercolor=white cellpadding=5 cellspacing=0><tr><td bgcolor=black width=40%><center><font color=white><b>Sire Info</b></font></center></td><td bgcolor=black width=40%><center><font color=white><b>Dam Info</b></font></center></td></tr>" . "<tr><td>Sire info would go here</td><td>Dam info would go here</td></tr></table><p>" . "<table width=80% border=1 bordercolor=white cellpadding=5 cellspacing=0><tr><td bgcolor=black width=40%><font color=white><center><b>Offspring</b></center></font><td bgcolor=black width=40%><font color=white><center><b>Notes</b></center></font></td></tr> " . "<tr><td>{$row['progeny']}</td><td>{$row['notes']}</td></tr></table><p>" . "<table width=80% border=1 bordercolor=white cellpadding=5 cellspacing=0><tr><td bgcolor=black><center><center><font color=white><b>Show Record</b></font></center></td></tr>" . "<tr><td>" . "<b>Competes In:</b> {$row['discipline']}<P>" . "{$row['showrecordlink']}</td></tr></table>" . "<p>" . "<table width=80% border=1 bordercolor=white cellpadding=5 cellspacing=0><tr><td bgcolor=black><center><center><font color=white><b>View Photos</b></font></center></td></tr>" . "<tr><td>" . "Not working, this really sucks!<P>"; } else{ $result=mysql_query("SELECT * FROM hlist"); while($row=mysql_fetch_array($result)){ echo("<tr><td><a href=?showdetails=$id>"."{$row['id']}</a></td>"."<td>{$row['title']} {$row['name']}</td>"."<td>{$row['year']}</td>"."<td>{$row['breed']}</td>"."<td>{$row['sex']}</td>"."<td>{$row['forsale']}</td>"."<td>{$row['canbreedto']}</td>"); } } ?>
  6. The site I am using this for is a secret santa database for a web group I'm a part of. Everything works fine, but I'm noticing that many members have more "gift items" than others. The table for gifts that have been sent (which I am wanting to count), records many presents for each individual, which is why I need to count the rows based on the column of "hfname". So in short, I want to count the rows, using the column hfname, and group them based on if the name shows up in 0, 1-3, 5-10, or 10+ rows. I want to set up the gift analysis like so: Members with no gifts (insert php to count hfname values returning 0 rows) Members with 1-3 gifts (insert php to count hfname values returning 1-3 rows) Members with 5-10 gifts (insert php to count hfname values returning 5-10 rows) Members with over 10 gifts (insert php to count hfname values returning >10 rows) --------------- This is really the first site I've done using databases, so it's more a learning tool than anything of real use, at least not unless it's the holidays =)
  7. Update: The query that had worked before is no longer working... [ SELECT sum(fee) FROM 'horses' WHERE boarder='Duli'; ] I'm not sure why all the sudden it doesn't work, maybe I copied what had worked down wrong or something. ALSO I'm wondering if it is possible to add the sum of the boarders fees (like in the query shown) and add the column named 'extrafees' to the total of 'fees'. I am leaving no rows in these two columns null, they are all valued 0 or greater.
  8. The site is: [a href=\"http://www.visionseq.com/listhorsesboarded2.php\" target=\"_blank\"]http://www.visionseq.com/listhorsesboarded2.php[/a] I am already have the list of horses boarded at my facility up and running. Now I would like to add all the rows in column 'boardfee' for each boarder. To do this I have used a SUM() function: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]SELECT SUM( boardfee ) FROM boarded WHERE boarder = 'Duli' I don't have many boarders, so I don't have a huge problem with having to do a query for every single boarder. There are currently only four. This query works when I use it in phpmyadmin, but I have NO idea how to use PHP to show the query results on a site. I have tried reading tutorials and what I put together obviously doesn't work correctly (click the link above, you'll see what I mean). Here is the code I used for the query... hopefully someone can lead me in the correct direction =) [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$query = "SELECT SUM( boardfee ) FROM boarded WHERE boarder = 'Duli'"; $result = mysql_query($query); { echo "<font color=white>"; echo "<b>Duli</b> owes $"; echo ($result); echo " each month"; } I am not sure if this is neccessary, but here is my coding to get the list of horses boarded that is currently functioning as it should: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] $result = mysql_query("SELECT * FROM boarded",$db); echo "<TABLE WIDTH=75% BORDER=2 BORDERCOLOR=BLACK CELLPADDING=2 CELLSPACING=0>"; echo"<TR BGCOLOR=ALICEBLUE><TD><B>Horse Name</B><TD><B>Located</B><TD><B>Owner</B><TD><B>Notes</B></TR>"; while ($myrow = mysql_fetch_array($result)) { echo "<TR BGCOLOR=WHITE><TD valign=top>"; echo $myrow["hname"]; echo "<td valign=top>"; echo $myrow["located"]; echo "<TD valign=top>"; echo $myrow["boarder"]; echo "<TD valign=top width=45%>"; echo $myrow["notes"]; } echo "</TABLE>";
×
×
  • 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.