Monday, 15 August 2011

Why is php not storing data in mysql? -



Why is php not storing data in mysql? -

i'm trying take links , store them in mysql table. not storing info getting error message(the 1 says "idk man, didnt in there"). i'm not sure i'm doing wrong. here's have far:

// create connection $conn = new mysqli($servername, $username, $password); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } else { echo "<font color='#00ff00'>connected database successfully</font><br>"; } //find open link record , insert foreach ($result $wtf) { //now show me mysqli_query ($conn,"insert carads (adlink) values ('$wtf')"); echo "<font color='#ffffff'>inserting link database: $wtf</font><br>"; } $sql="select 'adlink' 'carads'"; $sqlresult = mysqli_query($conn,$sql ); //if messed tell me if ( !$sqlresult) { echo mysqli_error($conn); die("<font size='20' color='#ff0000'>idk man, there error , dataset didnt in there</font><br>") ; } if ($sqlresult = mysqli_query($conn,$sql)) { // homecoming number of rows in result set $rowcount=mysqli_num_rows($sqlresult); print_r ("<font size='18' color='#00ff00'>car ads database has %d adlinks current city.\n</font><br>",$rowcount); // free result set mysqli_free_result($result); } //close connection mysqli_close($conn);

once again, im turned around here , needing little help smart people. why not storing links in database?

i modified of code. did not select database. there exist syntax error in sql string. seek this

$conn = mysqli_connect($servername, $username, $password, 'db_name'); if (mysqli_connect_error()){ die(mysqli_connect_error()); }else{ echo "<font color='#00ff00'>connected database successfully</font><br>"; } foreach ($result $wtf) { $result = mysqli_query ($conn,"insert carads (adlink) values ('$wtf')"); if(!$result){ die(mysqli_error($conn)); } echo "<font color='#ffffff'>inserting link database: $wtf</font><br>"; } $sql = "select adlink carads"; //removed single quotes here $sqlresult = mysqli_query($conn,$sql ); if(!$sqlresult){ echo mysqli_error($conn); die("<font size='20' color='#ff0000'>idk man, there error , dataset didnt in there</font><br>") ; } $rowcount=mysqli_num_rows($sqlresult); print_r ("<font size='18' color='#00ff00'>car ads database has %d adlinks current city.\n</font><br>",$rowcount); mysqli_free_result($result); mysqli_close($conn);

php mysql

No comments:

Post a Comment