mrsjprice Posted October 17, 2009 Share Posted October 17, 2009 I paid someone to design something for me which basically was - A form within my page, the data that goes into the form gets saved in a database, that information then gets pulled from the database to show 3lots of the information on my index.php with soonest at the top and then on my events.php page it shows ALL the information which has been submitted. Basically I have had a few problems with entering urls in the form (but I'll try and sort that out in a bit) But the script/whole process was working fine this morning but now it has just stopped working, when I submit the form it goes back to my index page as it should do but no data goes into the database and hence no data gets pulled to my pages. I don't have a clue whats not working the php coding looks ok but then Im not a coder. The code is listed below, can anyone spot anything or help me out please? I paid this guy to do this and now hes buggered off and wont get back to me. Ok submit.html (this is the where the form is) <p><u><strong>Submit an Event </strong></u></p> <p align="center">Use the form below to submit a midwifery event wether it's a conference, meeting or a study day.</p> <p align="center">Thank you</p> <p align="center"> </p> <p align="center"> </p> <p align="center" class="bigger"><form action="save-event.php" method="post"><table align="center" style="font-weight:bold;font-family:tahoma;font-size:12px;"><tr><td>Date:</td><td><input type="text" name="date"></td><td>Like:-dd.mm.yyyy, eg.20.10.1989</tr> <tr><td>Title:</td><td><input type="text" name="title"></td></tr> <tr><td>Description:</td><td><textarea name="desc"></textarea></td></tr> <tr><td>Link:</td><td><input type="text" name="link"></td><td>Like e.g. http://websitedomain.com or<br> http://www.websitedomain.com </td></tr> <tr><td colspan="2" align="center"><input type="submit" name="addevent" value="Add" style="border:1px;"></td></tr></table> </form> </p> This information submitted should then be proccessed by save-event.php - <?php $connection=mysql_connect("localhost","themidwi_kss","abc123") or die(mysql_error()); mysql_select_db("themidwi_pp31") or die(mysql_error()); function isValidURL($url) { return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url); } if((substr_count($_POST['date'],"."))<>2){ echo "<script language=javascript>alert(\"Enter the date in 'dd.mm.yyyy' format\");location.href='submit.html';</script>"; exit; } if(trim($_POST['link'])!="") { if(!isValidURL($_POST['link'])) { echo "<script language=javascript>alert(\"URL Not Correct HTTP(s) Missing\");location.href='submit.html';</script>"; exit; } } $date=explode(".",$_POST['date']); $sql = "insert into events values('','".$date['0']."','".$date['1']."','".$date['2']."','".$_POST['title']."','".$_POST['desc']."','".$_POST['link']."')"; $res=mysql_query($sql,$connection) or die(mysql_error()); header("location:index.php"); ?> Then this info should be pulled onto my index.php page - <?php $i=1; $connection=mysql_connect("localhost","themidwi_kss","abc123"); mysql_select_db("themidwi_pp31"); $sql="select * from events order by date,month"; $res=mysql_query($sql,$connection); $date=date("d"); $month=date("m"); $year=date("Y"); if(@mysql_num_rows($res)>0) { while($get_info=mysql_fetch_assoc($res)) { if($get_info['year']<$year) { mysql_query("delete from events where id='".$get_info['id']."'",$connection); continue; } else { if($i==4) break; if($get_info['month']<$month) { mysql_query("delete from events where id='".$get_info['id']."'",$connection); continue; } else { if($get_info['date']<$date) { mysql_query("delete from events where id='".$get_info['id']."'",$connection); continue; } else { echo "<img src=\"images/arr_gray.gif\" alt=\"\" width=\"3\" height=\"5\" hspace=\"10\">".$get_info['date'].".".$get_info['month'].".".$get_info['year']."<br> <span class=\"blue\"><img alt=\"\" src=\"images/spacer.gif\" width=\"23\" height=\"1\"><strong>".$get_info['title']."</strong></span><br> ".$get_info['descrip']." </p> <p align=\"right\"><span class=\"right_box_inner\">"; if($get_info['link']!="") { echo "<a href=\"".$get_info['link']."\" class=\"red\"><strong>Read More</strong></a>"; echo "<img src=\"images/arr.gif\" alt=\"\" width=\"3\" height=\"5\" hspace=\"5\"> "; } echo " </span><br> <div class=\"dotted_line\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" alt=\"\"></div>"; } } } $i++; } } else { echo "No Events For Future"; } ?> And on my events.php page - <?php $connection=mysql_connect("localhost","themidwi_kss","abc123"); mysql_select_db("themidwi_pp31"); $sql="select * from events order by date,month"; $res=mysql_query($sql,$connection); $date=date("d"); $month=date("m"); $year=date("Y"); if(@mysql_num_rows($res)>0) { while($get_info=mysql_fetch_assoc($res)) { if($get_info['year']<$year) { mysql_query("delete from events where id='".$get_info['id']."'",$connection); continue; } else { if($get_info['month']<$month) { mysql_query("delete from events where id='".$get_info['id']."'",$connection); continue; } else { if($get_info['date']<$date) { mysql_query("delete from events where id='".$get_info['id']."'",$connection); continue; } else { echo "<img src=\"images/arr_gray.gif\" alt=\"\" width=\"3\" height=\"5\" hspace=\"10\">".$get_info['date'].".".$get_info['month'].".".$get_info['year']."<br> <span class=\"blue\"><img alt=\"\" src=\"images/spacer.gif\" width=\"23\" height=\"1\"><strong>".$get_info['title']."</strong></span><br> ".$get_info['descrip']." <p align=\"right\"><span class=\"right_box_inner\">"; if($get_info['link']!="") { echo "<a href=\"".$get_info['link']."\" class=\"red\"><strong>Read More</strong></a>"; echo "<img src=\"images/arr.gif\" alt=\"\" width=\"3\" height=\"5\" hspace=\"5\"> "; } echo " </span><br> <div class=\"dotted_line\"><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" alt=\"\"></div>"; } } } } } else { echo "No Events For Future"; } ?> Can anyone help me please? XXX Link to comment https://forums.phpfreaks.com/topic/178053-script-was-working-now-its-not/ Share on other sites More sharing options...
teynon Posted October 17, 2009 Share Posted October 17, 2009 I haven't read through all of your code you posted, but most likely there is a database connection issue. You need to check the database name, username, and password. Link to comment https://forums.phpfreaks.com/topic/178053-script-was-working-now-its-not/#findComment-938827 Share on other sites More sharing options...
mrsjprice Posted October 17, 2009 Author Share Posted October 17, 2009 hI thanks for replying I delted the user it says at the top of the code and re created it with same name and password and reassigned it to the database, but yet its still not working. I don't get any php or mysql errors by the way. Link to comment https://forums.phpfreaks.com/topic/178053-script-was-working-now-its-not/#findComment-938855 Share on other sites More sharing options...
cags Posted October 17, 2009 Share Posted October 17, 2009 Does your server have error_reporting set to E_ALL and ini_set(display_errors, 1)? Link to comment https://forums.phpfreaks.com/topic/178053-script-was-working-now-its-not/#findComment-938877 Share on other sites More sharing options...
teynon Posted October 17, 2009 Share Posted October 17, 2009 Go through all of your submission code and put this on any statement that says "MySQL" " or die(mysql_error())" So $id_link=mysql_connect("blah", "blah", "blah") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/178053-script-was-working-now-its-not/#findComment-938880 Share on other sites More sharing options...
mrsjprice Posted October 17, 2009 Author Share Posted October 17, 2009 err to the 2nd to last poster, I don't have a clue if my server has that. I tried adding this - So $id_link=mysql_connect("blah", "blah", "blah") or die(mysql_error()); after this $connection=mysql_connect("localhost","themidwi_kss","abc123") or die(mysql_error()); And it came up with a t-string error. Sorry I don't know php that well, if you tell me what to put where or what after or before, I can do that in a jiffy otherwise im in limbo. Sorry Link to comment https://forums.phpfreaks.com/topic/178053-script-was-working-now-its-not/#findComment-938882 Share on other sites More sharing options...
teynon Posted October 17, 2009 Share Posted October 17, 2009 Please copy and paste the error exactly Link to comment https://forums.phpfreaks.com/topic/178053-script-was-working-now-its-not/#findComment-938883 Share on other sites More sharing options...
mrsjprice Posted October 17, 2009 Author Share Posted October 17, 2009 Warning: Wrong parameter count for mysql_select_db() in /home/themidwi/public_html/save-event.php on line 3 Link to comment https://forums.phpfreaks.com/topic/178053-script-was-working-now-its-not/#findComment-938886 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.